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: Sync locale docs with OpenCode
  45. if: steps.changes.outputs.has_changes == 'true'
  46. uses: sst/opencode/github@latest
  47. env:
  48. OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }}
  49. GITHUB_TOKEN: ${{ steps.committer.outputs.token }}
  50. OPENCODE_CONFIG_CONTENT: |
  51. {
  52. "permission": {
  53. "*": "deny",
  54. "read": {
  55. "*": "deny",
  56. "packages/web/src/content/docs": "allow",
  57. "packages/web/src/content/docs/*": "allow",
  58. "packages/web/src/content/docs/*.mdx": "allow",
  59. "packages/web/src/content/docs/*/*.mdx": "allow",
  60. ".opencode": "allow",
  61. ".opencode/agent": "allow",
  62. ".opencode/agent/glossary": "allow",
  63. ".opencode/agent/translator.md": "allow",
  64. ".opencode/agent/glossary/*.md": "allow"
  65. },
  66. "edit": {
  67. "*": "deny",
  68. "packages/web/src/content/docs/*/*.mdx": "allow"
  69. },
  70. "glob": {
  71. "*": "deny",
  72. "packages/web/src/content/docs*": "allow",
  73. ".opencode/agent/glossary*": "allow"
  74. },
  75. "task": {
  76. "*": "deny",
  77. "translator": "allow"
  78. }
  79. },
  80. "agent": {
  81. "translator": {
  82. "permission": {
  83. "*": "deny",
  84. "read": {
  85. "*": "deny",
  86. ".opencode/agent/translator.md": "allow",
  87. ".opencode/agent/glossary/*.md": "allow"
  88. }
  89. }
  90. }
  91. }
  92. }
  93. with:
  94. model: opencode/gpt-5.3-codex
  95. agent: docs
  96. use_github_token: true
  97. prompt: |
  98. Update localized docs to match the latest English docs changes.
  99. Changed English doc files:
  100. <changed_english_docs>
  101. ${{ steps.changes.outputs.files }}
  102. </changed_english_docs>
  103. Requirements:
  104. 1. Update all relevant locale docs under packages/web/src/content/docs/<locale>/ so they reflect these English page changes.
  105. 2. You MUST use the Task tool for translation work and launch subagents with subagent_type `translator` (defined in .opencode/agent/translator.md).
  106. 3. Do not translate directly in the primary agent. Use translator subagent output as the source for locale text updates.
  107. 4. Run translator subagent Task calls in parallel whenever file/locale translation work is independent.
  108. 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.
  109. 6. Preserve frontmatter keys, internal links, code blocks, and existing locale-specific metadata unless the English change requires an update.
  110. 7. Keep locale docs structure aligned with their corresponding English pages.
  111. 8. Do not modify English source docs in packages/web/src/content/docs/*.mdx.
  112. 9. If no locale updates are needed, make no changes.
  113. - name: Commit and push locale docs updates
  114. if: steps.changes.outputs.has_changes == 'true'
  115. run: |
  116. if [ -z "$(git status --porcelain)" ]; then
  117. echo "No locale docs changes to commit"
  118. exit 0
  119. fi
  120. git add -A
  121. git commit -m "docs(i18n): sync locale docs from english changes"
  122. git pull --rebase --autostash origin "$GITHUB_REF_NAME"
  123. git push origin HEAD:"$GITHUB_REF_NAME"