-
Notifications
You must be signed in to change notification settings - Fork 15
63 lines (60 loc) · 2.2 KB
/
Copy pathtranslate.yml
File metadata and controls
63 lines (60 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
name: Translate Docs
on:
push:
branches: [master]
paths:
- 'docs/**'
- 'scripts/translate.mjs'
- 'scripts/translate.config.json'
# nav / sidebar labels are derived from these, so changes here re-translate the UI JSON
- 'sidebars.ts'
- 'docusaurus.config.ts'
workflow_dispatch:
permissions:
contents: write
id-token: write
actions: write
# The commit this workflow makes only touches i18n/**, which is NOT in the
# trigger paths above, so it will not re-trigger itself.
jobs:
translate:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: npm ci
# Refresh the English baseline + locale scaffolding for the navbar/sidebar UI labels.
# The translate step diffs against it; scaffolding byproducts we don't own are cleaned
# up by the script (see cleanupAfter in translate.config.json).
- name: Scaffold UI translations
run: npm run i18n:scaffold
# The translate script shells out to the Claude CLI (`claude -p`); the runner doesn't
# ship it. The CLI reads ANTHROPIC_API_KEY from the env automatically (set on the
# Translate step below), so no `claude` login/config is needed in CI.
- name: Install Claude CLI
run: npm install -g @anthropic-ai/claude-code
- name: Translate
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
run: npm run translate
- name: Commit and Push
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add i18n
if git diff --staged --quiet; then
echo "No translation changes to commit."
else
echo "Translation changes detected. Committing..."
git commit -m "automatic translation update"
git push
echo "Dispatching deploy workflow..."
gh workflow run deploy.yml --ref master
fi