|
| 1 | +name: "Update Translated Docs" |
| 2 | + |
| 3 | +# This GitHub Actions job automates the process of updating all translated document pages. Please note the following: |
| 4 | +# 1. The translation results may vary each time; some differences in detail are expected. |
| 5 | +# 2. When you add a new page to the left-hand menu, **make sure to manually update mkdocs.yml** to include the new item. |
| 6 | +# 3. If you switch to a different LLM (for example, from o3 to a newer model), be sure to conduct thorough testing before making the switch. |
| 7 | + |
| 8 | +# To add more languages, you will update the following: |
| 9 | +# 1. Add '!docs/{lang}/**' to `on.push.paths` in this file |
| 10 | +# 2. Update mkdocs.yml to have the new language |
| 11 | +# 3. Update docs/scripts/translate_docs.py to have the new language |
| 12 | + |
| 13 | +on: |
| 14 | + push: |
| 15 | + branches: |
| 16 | + - main |
| 17 | + paths: |
| 18 | + - 'docs/**' |
| 19 | + - mkdocs.yml |
| 20 | + - '!docs/ja/**' |
| 21 | + - '!docs/ko/**' |
| 22 | + - '!docs/zh/**' |
| 23 | + |
| 24 | +permissions: |
| 25 | + contents: write |
| 26 | + pull-requests: write |
| 27 | + |
| 28 | +jobs: |
| 29 | + update-docs: |
| 30 | + if: "!contains(github.event.head_commit.message, 'Update all translated document pages')" |
| 31 | + name: Build and Push Translated Docs |
| 32 | + runs-on: ubuntu-latest |
| 33 | + timeout-minutes: 20 |
| 34 | + env: |
| 35 | + PROD_OPENAI_API_KEY: ${{ secrets.PROD_OPENAI_API_KEY }} |
| 36 | + steps: |
| 37 | + - name: Checkout repository |
| 38 | + uses: actions/checkout@v3 |
| 39 | + with: |
| 40 | + fetch-depth: 0 |
| 41 | + - name: Setup uv |
| 42 | + uses: astral-sh/setup-uv@v5 |
| 43 | + with: |
| 44 | + enable-cache: true |
| 45 | + - name: Install dependencies |
| 46 | + run: make sync |
| 47 | + - name: Build full docs |
| 48 | + run: make build-full-docs |
| 49 | + |
| 50 | + - name: Commit changes |
| 51 | + id: commit |
| 52 | + run: | |
| 53 | + git config user.name "github-actions[bot]" |
| 54 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 55 | + git add docs/ |
| 56 | + if [ -n "$(git status --porcelain)" ]; then |
| 57 | + git commit -m "Update all translated document pages" |
| 58 | + echo "committed=true" >> "$GITHUB_OUTPUT" |
| 59 | + else |
| 60 | + echo "No changes to commit" |
| 61 | + echo "committed=false" >> "$GITHUB_OUTPUT" |
| 62 | + fi |
| 63 | +
|
| 64 | + - name: Create Pull Request |
| 65 | + if: steps.commit.outputs.committed == 'true' |
| 66 | + uses: peter-evans/create-pull-request@v6 |
| 67 | + with: |
| 68 | + commit-message: "Update all translated document pages" |
| 69 | + title: "Update all translated document pages" |
| 70 | + body: | |
| 71 | + Automated update of translated documentation. |
| 72 | +
|
| 73 | + Triggered by commit: [${{ github.event.head_commit.id }}](${{ github.server_url }}/${{ github.repository }}/commit/${{ github.event.head_commit.id }}). |
| 74 | + Message: `${{ github.event.head_commit.message }}` |
| 75 | + branch: update-translated-docs-${{ github.run_id }} |
| 76 | + delete-branch: true |
0 commit comments