|
1 | | -name: Check Documentation Updates |
| 1 | +name: Sync Affinity v1 Docs |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | schedule: |
5 | | - # Run daily at 00:00 UTC |
6 | | - - cron: '0 0 * * *' |
| 5 | + - cron: "0 0 * * *" |
7 | 6 | workflow_dispatch: |
8 | | - inputs: |
9 | | - api_version: |
10 | | - description: 'API version to check (v1, v2, or all)' |
11 | | - required: false |
12 | | - default: 'all' |
13 | | - type: choice |
14 | | - options: |
15 | | - - all |
16 | | - - v1 |
17 | | - - v2 |
18 | | - force_check: |
19 | | - description: 'Force check even if recently checked' |
20 | | - required: false |
21 | | - default: false |
22 | | - type: boolean |
23 | 7 |
|
24 | | -jobs: |
25 | | - # Run tests first to ensure code quality before attempting updates |
26 | | - test: |
27 | | - runs-on: ubuntu-latest |
28 | | - steps: |
29 | | - - name: Checkout repository |
30 | | - uses: actions/checkout@v4 |
31 | | - |
32 | | - - name: Set up Python |
33 | | - uses: actions/setup-python@v5 |
34 | | - with: |
35 | | - python-version: '3.11' |
36 | | - cache: 'pip' |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + pull-requests: write |
37 | 11 |
|
38 | | - - name: Install dependencies |
39 | | - run: | |
40 | | - python -m pip install --upgrade pip |
41 | | - pip install -r requirements-ci.txt |
42 | | -
|
43 | | - - name: Run tests |
44 | | - run: | |
45 | | - pytest tests/ -m "not integration" --tb=short |
46 | | -
|
47 | | - check-updates: |
48 | | - needs: test # Only run if tests pass |
| 12 | +jobs: |
| 13 | + sync-docs: |
49 | 14 | runs-on: ubuntu-latest |
50 | | - permissions: |
51 | | - contents: write |
52 | | - pull-requests: write |
53 | | - issues: read |
54 | | - |
55 | 15 | steps: |
56 | 16 | - name: Checkout repository |
57 | 17 | uses: actions/checkout@v4 |
58 | 18 | with: |
59 | | - fetch-depth: 0 # Full history for diff generation |
| 19 | + fetch-depth: 0 |
60 | 20 |
|
61 | 21 | - name: Set up Python |
62 | 22 | uses: actions/setup-python@v5 |
63 | 23 | with: |
64 | | - python-version: '3.11' |
65 | | - cache: 'pip' |
| 24 | + python-version: "3.11" |
| 25 | + cache: "pip" |
66 | 26 |
|
67 | 27 | - name: Install dependencies |
68 | 28 | run: | |
69 | 29 | python -m pip install --upgrade pip |
70 | 30 | pip install -r requirements-ci.txt |
71 | 31 |
|
72 | | - - name: Install GitHub CLI |
| 32 | + - name: Sync documentation |
| 33 | + id: sync_docs |
73 | 34 | run: | |
74 | | - type -p curl >/dev/null || sudo apt-get update && sudo apt-get install -y curl |
75 | | - curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg |
76 | | - sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg |
77 | | - echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null |
78 | | - sudo apt-get update |
79 | | - sudo apt-get install -y gh |
| 35 | + set +e |
| 36 | + python tools/v1_sync_pipeline/sync_v1_docs.py --fail-on-diff |
| 37 | + status=$? |
| 38 | + set -e |
| 39 | + if [ "$status" -eq 0 ]; then |
| 40 | + echo "changes=false" >> "$GITHUB_OUTPUT" |
| 41 | + exit 0 |
| 42 | + fi |
| 43 | + if [ "$status" -eq 1 ]; then |
| 44 | + echo "changes=true" >> "$GITHUB_OUTPUT" |
| 45 | + exit 0 |
| 46 | + fi |
| 47 | + exit "$status" |
80 | 48 |
|
81 | | - - name: Configure GitHub CLI |
82 | | - env: |
83 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
84 | | - run: | |
85 | | - gh auth setup-git |
86 | | - gh auth status |
87 | | -
|
88 | | - - name: Configure Git |
89 | | - run: | |
90 | | - git config --global user.name "github-actions[bot]" |
91 | | - git config --global user.email "github-actions[bot]@users.noreply.github.com" |
| 49 | + - name: Run link checker |
| 50 | + run: python tools/v1_sync_pipeline/qa/check_links.py docs/v1/affinity_api_docs.md |
92 | 51 |
|
93 | | - - name: Check and update documentation |
94 | | - env: |
95 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
96 | | - API_VERSION: ${{ github.event.inputs.api_version || 'all' }} |
97 | | - FORCE_CHECK: ${{ github.event.inputs.force_check || 'false' }} |
98 | | - run: | |
99 | | - python .github/scripts/check_and_update_docs.py --api-version "$API_VERSION" --force-check "$FORCE_CHECK" |
| 52 | + - name: Create pull request |
| 53 | + if: steps.sync_docs.outputs.changes == 'true' |
| 54 | + uses: peter-evans/create-pull-request@v6 |
| 55 | + with: |
| 56 | + commit-message: "chore: sync Affinity v1 docs" |
| 57 | + title: "chore: sync Affinity v1 docs" |
| 58 | + body: | |
| 59 | + Automated sync of Affinity API v1 documentation. |
| 60 | + branch: chore/sync-v1-docs |
| 61 | + delete-branch: true |
100 | 62 |
|
101 | 63 | - name: Summary |
102 | 64 | if: always() |
103 | 65 | run: | |
104 | | - echo "## Documentation Update Check Complete" >> $GITHUB_STEP_SUMMARY |
105 | | - echo "" >> $GITHUB_STEP_SUMMARY |
106 | | - echo "Check completed at $(date -u +'%Y-%m-%d %H:%M:%S UTC')" >> $GITHUB_STEP_SUMMARY |
| 66 | + echo "## Sync summary" >> "$GITHUB_STEP_SUMMARY" |
| 67 | + echo "" >> "$GITHUB_STEP_SUMMARY" |
| 68 | + echo "- Changes detected: ${{ steps.sync_docs.outputs.changes || 'false' }}" >> "$GITHUB_STEP_SUMMARY" |
| 69 | + echo "- Run completed at $(date -u +'%Y-%m-%d %H:%M:%S UTC')" >> "$GITHUB_STEP_SUMMARY" |
0 commit comments