2
0

docs-locale-sync.yml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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: false
  11. #if: github.actor != 'opencode-agent[bot]'
  12. runs-on: blacksmith-4vcpu-ubuntu-2404
  13. permissions:
  14. contents: write
  15. steps:
  16. - name: Checkout repository
  17. uses: actions/checkout@v4
  18. with:
  19. persist-credentials: false
  20. fetch-depth: 0
  21. ref: ${{ github.ref_name }}
  22. - name: Setup Bun
  23. uses: ./.github/actions/setup-bun
  24. - name: Setup git committer
  25. id: committer
  26. uses: ./.github/actions/setup-git-committer
  27. with:
  28. opencode-app-id: ${{ vars.OPENCODE_APP_ID }}
  29. opencode-app-secret: ${{ secrets.OPENCODE_APP_SECRET }}
  30. - name: Compute changed English docs
  31. id: changes
  32. run: |
  33. FILES=$(git diff --name-only "${{ github.event.before }}" "${{ github.sha }}" -- ':(glob)packages/web/src/content/docs/*.mdx' || true)
  34. if [ -z "$FILES" ]; then
  35. echo "has_changes=false" >> "$GITHUB_OUTPUT"
  36. echo "No English docs changed in push range"
  37. exit 0
  38. fi
  39. echo "has_changes=true" >> "$GITHUB_OUTPUT"
  40. {
  41. echo "files<<EOF"
  42. echo "$FILES"
  43. echo "EOF"
  44. } >> "$GITHUB_OUTPUT"
  45. - name: Install OpenCode
  46. if: steps.changes.outputs.has_changes == 'true'
  47. run: curl -fsSL https://opencode.ai/install | bash
  48. - name: Sync locale docs with OpenCode
  49. if: steps.changes.outputs.has_changes == 'true'
  50. env:
  51. OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }}
  52. OPENCODE_CONFIG_CONTENT: |
  53. {
  54. "permission": {
  55. "*": "deny",
  56. "read": "allow",
  57. "edit": "allow",
  58. "glob": "allow",
  59. "task": "allow"
  60. }
  61. }
  62. run: |
  63. opencode run --agent docs --model opencode/gpt-5.3-codex <<'EOF'
  64. Update localized docs to match the latest English docs changes.
  65. Changed English doc files:
  66. <changed_english_docs>
  67. ${{ steps.changes.outputs.files }}
  68. </changed_english_docs>
  69. Requirements:
  70. 1. Update all relevant locale docs under packages/web/src/content/docs/<locale>/ so they reflect these English page changes.
  71. 2. You MUST use the Task tool for translation work and launch subagents with subagent_type `translator` (defined in .opencode/agent/translator.md).
  72. 3. Do not translate directly in the primary agent. Use translator subagent output as the source for locale text updates.
  73. 4. Run translator subagent Task calls in parallel whenever file/locale translation work is independent.
  74. 5. Use only the minimum tools needed for this task (read/glob, file edits, and translator Task). Do not use shell, web, search, or GitHub tools for translation work.
  75. 6. Preserve frontmatter keys, internal links, code blocks, and existing locale-specific metadata unless the English change requires an update.
  76. 7. Keep locale docs structure aligned with their corresponding English pages.
  77. 8. Do not modify English source docs in packages/web/src/content/docs/*.mdx.
  78. 9. If no locale updates are needed, make no changes.
  79. EOF
  80. - name: Commit and push locale docs updates
  81. if: steps.changes.outputs.has_changes == 'true'
  82. run: |
  83. if [ -z "$(git status --porcelain)" ]; then
  84. echo "No locale docs changes to commit"
  85. exit 0
  86. fi
  87. git add -A
  88. git commit -m "docs(i18n): sync locale docs from english changes"
  89. git pull --rebase --autostash origin "$GITHUB_REF_NAME"
  90. git push origin HEAD:"$GITHUB_REF_NAME"