-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (72 loc) · 2.67 KB
/
check-docs-updates.yml
File metadata and controls
81 lines (72 loc) · 2.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
name: Sync Affinity Docs
on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
permissions:
contents: write
pull-requests: write
actions: write
jobs:
sync-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11.4"
cache: "pip"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-ci.txt
- name: Sync documentation
id: sync_docs
run: |
set -euo pipefail
python tools/v1_sync_pipeline/sync_v1_docs.py --summary-file "$GITHUB_STEP_SUMMARY"
python tools/v2_sync_pipeline/sync_v2_docs.py --snapshot-dir tmp/v2
python tools/v1_sync_pipeline/qa/check_links.py docs/v1/affinity_api_docs.md
python tools/v1_sync_pipeline/qa/check_links.py docs/v2/affinity_api_docs.md
if git status --short docs/v1 docs/v2 | grep .; then
echo "changes=true" >> "$GITHUB_OUTPUT"
else
echo "changes=false" >> "$GITHUB_OUTPUT"
fi
- name: Trigger Tests and Pre-commit workflows
if: steps.sync_docs.outputs.changes == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
BRANCH: chore/sync-affinity-docs
run: |
set -euo pipefail
for workflow in tests.yml pre-commit.yml; do
curl -X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/$REPO/actions/workflows/$workflow/dispatches" \
-d "{\"ref\":\"$BRANCH\"}"
done
- name: Create pull request
if: steps.sync_docs.outputs.changes == 'true'
uses: peter-evans/create-pull-request@v7
with:
commit-message: "chore: sync Affinity API docs"
title: "chore: sync Affinity API docs"
body: |
Automated sync of Affinity API v1 and v2 documentation.
branch: chore/sync-affinity-docs
delete-branch: true
- name: Summary
if: always()
run: |
echo "## Sync summary" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "- Changes detected: ${{ steps.sync_docs.outputs.changes || 'false' }}" >> "$GITHUB_STEP_SUMMARY"
echo "- Run completed at $(date -u +'%Y-%m-%d %H:%M:%S UTC')" >> "$GITHUB_STEP_SUMMARY"