docs-locale-sync.yml 5.1 KB

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