Sync Affinity Docs #154
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" |