sync-docs #11
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 Docs from PlatformBackend | |
| on: | |
| repository_dispatch: | |
| types: [sync-docs] | |
| workflow_dispatch: | |
| inputs: | |
| force: | |
| description: "Force full regeneration" | |
| required: false | |
| default: "false" | |
| type: boolean | |
| skip_translate: | |
| description: "Skip translation step" | |
| required: false | |
| default: "false" | |
| type: boolean | |
| schedule: | |
| - cron: "0 6 * * *" # Daily at 6:00 UTC | |
| permissions: | |
| contents: write | |
| env: | |
| PYTHONUNBUFFERED: "1" | |
| jobs: | |
| sync: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 60 | |
| steps: | |
| - name: Checkout Docs repo | |
| uses: actions/checkout@v4 | |
| with: | |
| path: Docs | |
| token: ${{ secrets.BOT_TOKEN }} | |
| - name: Checkout PlatformBackend | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: AceDataCloud/PlatformBackend | |
| path: PlatformBackend | |
| token: ${{ secrets.BOT_TOKEN }} | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Restore cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: Docs/.cache | |
| key: docs-cache-${{ hashFiles('Docs/scripts/*.py') }}-${{ github.run_number }} | |
| restore-keys: | | |
| docs-cache-${{ hashFiles('Docs/scripts/*.py') }}- | |
| docs-cache- | |
| - name: Run sync script (Chinese base content) | |
| timeout-minutes: 15 | |
| env: | |
| ACEDATACLOUD_OPENAI_KEY: ${{ secrets.ACEDATACLOUD_OPENAI_KEY }} | |
| run: | | |
| echo "::group::Sync script output" | |
| cd Docs | |
| python -u scripts/sync.py \ | |
| --backend-dir ../PlatformBackend \ | |
| --output-dir . | |
| echo "::endgroup::" | |
| - name: Enhance content (optional) | |
| if: inputs.force == 'true' | |
| timeout-minutes: 20 | |
| env: | |
| ACEDATACLOUD_OPENAI_KEY: ${{ secrets.ACEDATACLOUD_OPENAI_KEY }} | |
| run: | | |
| echo "::group::Enhance content" | |
| cd Docs | |
| python -u scripts/enhance_content.py --output-dir . | |
| echo "::endgroup::" | |
| - name: Translate to all languages | |
| if: inputs.skip_translate != 'true' | |
| timeout-minutes: 45 | |
| env: | |
| ACEDATACLOUD_OPENAI_KEY: ${{ secrets.ACEDATACLOUD_OPENAI_KEY }} | |
| run: | | |
| echo "::group::Translation output" | |
| cd Docs | |
| # Only translate root-level MDX files (intro, quickstart, auth) and | |
| # generated static pages that don't come from PlatformBackend. | |
| # PlatformBackend translations are already copied by sync.py step 6b. | |
| python -u scripts/translate_content.py --output-dir . --root-only | |
| echo "::endgroup::" | |
| - name: Check for changes | |
| id: changes | |
| working-directory: Docs | |
| run: | | |
| git add -A | |
| if git diff --cached --quiet; then | |
| echo "changed=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "changed=true" >> "$GITHUB_OUTPUT" | |
| echo "Files changed:" | |
| git diff --cached --name-only | head -100 | |
| fi | |
| - name: Commit and push | |
| if: steps.changes.outputs.changed == 'true' | |
| working-directory: Docs | |
| run: | | |
| git config user.name "Ace Data Cloud Dev" | |
| git config user.email "dev@acedata.cloud" | |
| git commit -m "docs: sync from PlatformBackend (zh-CN base + translations) [automated]" | |
| git push |