Update Step 3.5 with full CYOA interface registration guide (#157) #4
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: Auto-translate docs | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - 'docs/**.md' | |
| jobs: | |
| translate: | |
| runs-on: ubuntu-latest | |
| # Prevent infinite loop: skip when the bot itself pushes translations | |
| if: github.event.head_commit.author.name != 'github-actions[bot]' | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 2 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - run: pip install anthropic | |
| - name: Find changed source docs | |
| id: changed | |
| run: | | |
| BASE=$(git rev-parse HEAD~1 2>/dev/null || git hash-object -t tree /dev/null) | |
| # Only source .md files — exclude already-translated ones (e.g. index.es.md) | |
| CHANGED=$(git diff --name-only "$BASE" HEAD -- docs/ \ | |
| | grep '\.md$' \ | |
| | grep -vE '\.[a-z]{2,3}\.md$' \ | |
| || true) | |
| echo "Source files changed:" | |
| echo "$CHANGED" | |
| { | |
| echo "files<<EOF" | |
| echo "$CHANGED" | |
| echo "EOF" | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Translate | |
| if: steps.changed.outputs.files != '' | |
| env: | |
| ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} | |
| CHANGED_FILES: ${{ steps.changed.outputs.files }} | |
| LANGUAGES: "zh,ja,ko,pt,es,fr,it" | |
| run: python scripts/translate.py | |
| - name: Commit translations | |
| if: steps.changed.outputs.files != '' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git add docs/ | |
| git diff --cached --quiet || git commit -m "chore: auto-translate docs" | |
| git push |