Skip to content

🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.

Refactor translation workflow to separate translation checks and manual triggers, enhancing automation and clarity in localization processes. Update permissions and job names for improved workflow management.

Bill Yang091caa1d3de8
diff --git a/.github/workflows/translate-docs.yml b/.github/workflows/translate-docs.yml
index 325d1fcdc..0a0313cc3 100644
--- a/.github/workflows/translate-docs.yml
+++ b/.github/workflows/translate-docs.yml
@@ -6,15 +6,15 @@ on:
paths:
- "docs/src/**/*.ts"
- "docs/src/**/*.tsx"
- workflow_dispatch: # Allow manual trigger
+ workflow_dispatch:
jobs:
- translate:
+ check:
+ if: github.event_name == 'push'
runs-on: ubuntu-latest
permissions:
- contents: write
- pull-requests: write
- id-token: write
+ actions: write
+ contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
@@ -36,7 +36,6 @@ jobs:
id: changes
run: |
cd docs/messages
- # Check if any non-English file has empty string values or is missing keys from en.json
EN_KEYS=$(python3 -c "import json; f=open('en.json'); d=json.load(f); print(len(d))")
NEEDS_TRANSLATION=false
for file in zh.json ja.json de.json pl.json pt.json it.json fr.json ko.json es.json; do
@@ -49,9 +48,37 @@ jobs:
done
echo "has_changes=$NEEDS_TRANSLATION" >> "$GITHUB_OUTPUT"
- - name: Run Claude Code
+ - name: Trigger translation workflow
if: steps.changes.outputs.has_changes == 'true'
- id: claude
+ run: gh workflow run translate-docs.yml --ref master
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+
+ translate:
+ if: github.event_name == 'workflow_dispatch'
+ runs-on: ubuntu-latest
+ permissions:
+ contents: write
+ pull-requests: write
+ id-token: write
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v4
+ with:
+ fetch-depth: 1
+
+ - name: Setup Node.js
+ uses: actions/setup-node@v4
+ with:
+ node-version: 20
+
+ - name: Install dependencies
+ run: cd docs && npm ci
+
+ - name: Extract messages
+ run: cd docs && node scripts/extract-messages.mjs
+
+ - name: Run Claude Code
uses: anthropics/claude-code-action@v1
with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}