docs-locale-sync.yml 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. name: docs-locale-sync
  2. on:
  3. push:
  4. branches:
  5. - dev
  6. paths:
  7. - packages/web/src/content/docs/*.mdx
  8. jobs:
  9. sync-locales:
  10. if: github.actor != 'opencode-agent[bot]'
  11. runs-on: blacksmith-4vcpu-ubuntu-2404
  12. permissions:
  13. id-token: write
  14. contents: write
  15. steps:
  16. - name: Checkout repository
  17. uses: actions/checkout@v4
  18. with:
  19. fetch-depth: 0
  20. - name: Setup Bun
  21. uses: ./.github/actions/setup-bun
  22. - name: Setup git committer
  23. id: committer
  24. uses: ./.github/actions/setup-git-committer
  25. with:
  26. opencode-app-id: ${{ vars.OPENCODE_APP_ID }}
  27. opencode-app-secret: ${{ secrets.OPENCODE_APP_SECRET }}
  28. - name: Compute changed English docs
  29. id: changes
  30. run: |
  31. FILES=$(git diff --name-only "${{ github.event.before }}" "${{ github.sha }}" -- 'packages/web/src/content/docs/*.mdx' || true)
  32. if [ -z "$FILES" ]; then
  33. echo "has_changes=false" >> "$GITHUB_OUTPUT"
  34. echo "No English docs changed in push range"
  35. exit 0
  36. fi
  37. echo "has_changes=true" >> "$GITHUB_OUTPUT"
  38. {
  39. echo "files<<EOF"
  40. echo "$FILES"
  41. echo "EOF"
  42. } >> "$GITHUB_OUTPUT"
  43. - name: Sync locale docs with OpenCode
  44. if: steps.changes.outputs.has_changes == 'true'
  45. uses: sst/opencode/github@latest
  46. env:
  47. OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }}
  48. with:
  49. model: opencode/gpt-5.2
  50. agent: docs
  51. prompt: |
  52. Update localized docs to match the latest English docs changes.
  53. Changed English doc files:
  54. <changed_english_docs>
  55. ${{ steps.changes.outputs.files }}
  56. </changed_english_docs>
  57. Requirements:
  58. 1. Update all relevant locale docs under packages/web/src/content/docs/<locale>/ so they reflect these English page changes.
  59. 2. Preserve frontmatter keys, internal links, code blocks, and existing locale-specific metadata unless the English change requires an update.
  60. 3. Keep locale docs structure aligned with their corresponding English pages.
  61. 4. Do not modify English source docs in packages/web/src/content/docs/*.mdx.
  62. 5. If no locale updates are needed, make no changes.
  63. - name: Commit and push locale docs updates
  64. if: steps.changes.outputs.has_changes == 'true'
  65. run: |
  66. if [ -z "$(git status --porcelain)" ]; then
  67. echo "No locale docs changes to commit"
  68. exit 0
  69. fi
  70. git add -A
  71. git commit -m "docs(i18n): sync locale docs from english changes"
  72. git pull --rebase --autostash origin "$GITHUB_REF_NAME"
  73. git push origin HEAD:"$GITHUB_REF_NAME"