fix(i18n): resolve Claude Code sandbox path issues in workflow (#30710)

This commit is contained in:
yyh 2026-01-08 09:53:32 +08:00 committed by GitHub
parent 7ccf858ce6
commit 25ff4ae5da
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -132,6 +132,14 @@ jobs:
- Use **Edit** tool to modify JSON files (NOT node, jq, or bash scripts) - Use **Edit** tool to modify JSON files (NOT node, jq, or bash scripts)
- Use **Bash** ONLY for: git commands, gh commands, pnpm commands - Use **Bash** ONLY for: git commands, gh commands, pnpm commands
- Run bash commands ONE BY ONE, never combine with && or || - Run bash commands ONE BY ONE, never combine with && or ||
- NEVER use `$()` command substitution - it's not supported. Split into separate commands instead.
## WORKING DIRECTORY & ABSOLUTE PATHS
Claude Code sandbox working directory may vary. Always use absolute paths:
- For pnpm: `pnpm --dir ${{ github.workspace }}/web <command>`
- For git: `git -C ${{ github.workspace }} <command>`
- For gh: `gh --repo ${{ github.repository }} <command>`
- For file paths: `${{ github.workspace }}/web/i18n/`
## EFFICIENCY RULES ## EFFICIENCY RULES
- **ONE Edit per language file** - batch all key additions into a single Edit - **ONE Edit per language file** - batch all key additions into a single Edit
@ -142,8 +150,8 @@ jobs:
- Changed/target files: ${{ steps.detect_changes.outputs.CHANGED_FILES }} - Changed/target files: ${{ steps.detect_changes.outputs.CHANGED_FILES }}
- Target languages (empty means all supported): ${{ steps.detect_changes.outputs.TARGET_LANGS }} - Target languages (empty means all supported): ${{ steps.detect_changes.outputs.TARGET_LANGS }}
- Sync mode: ${{ steps.detect_changes.outputs.SYNC_MODE }} - Sync mode: ${{ steps.detect_changes.outputs.SYNC_MODE }}
- Translation files are located in: web/i18n/{locale}/{filename}.json - Translation files are located in: ${{ github.workspace }}/web/i18n/{locale}/{filename}.json
- Language configuration is in: web/i18n-config/languages.ts - Language configuration is in: ${{ github.workspace }}/web/i18n-config/languages.ts
- Git diff is available: ${{ steps.detect_changes.outputs.DIFF_AVAILABLE }} - Git diff is available: ${{ steps.detect_changes.outputs.DIFF_AVAILABLE }}
## CRITICAL DESIGN: Verify First, Then Sync ## CRITICAL DESIGN: Verify First, Then Sync
@ -166,13 +174,15 @@ jobs:
* DELETE: Keys that appear only in `-` lines (removed keys) * DELETE: Keys that appear only in `-` lines (removed keys)
### Step 1.2: Read Language Configuration ### Step 1.2: Read Language Configuration
Use the Read tool to read `web/i18n-config/languages.ts`. Use the Read tool to read `${{ github.workspace }}/web/i18n-config/languages.ts`.
Extract all languages with `supported: true`. Extract all languages with `supported: true`.
### Step 1.3: Run i18n:check for Each Language ### Step 1.3: Run i18n:check for Each Language
```bash ```bash
pnpm --dir web install --frozen-lockfile pnpm --dir ${{ github.workspace }}/web install --frozen-lockfile
pnpm --dir web run i18n:check ```
```bash
pnpm --dir ${{ github.workspace }}/web run i18n:check
``` ```
This will report: This will report:
@ -234,7 +244,7 @@ jobs:
**IMPORTANT: Special handling for zh-Hans and ja-JP** **IMPORTANT: Special handling for zh-Hans and ja-JP**
If zh-Hans or ja-JP files were ALSO modified in the same push: If zh-Hans or ja-JP files were ALSO modified in the same push:
- Run: `git diff HEAD~1 --name-only | grep -E "(zh-Hans|ja-JP)"` - Run: `git -C ${{ github.workspace }} diff HEAD~1 --name-only` and check for zh-Hans or ja-JP files
- If found, it means someone manually translated them. Apply these rules: - If found, it means someone manually translated them. Apply these rules:
1. **Missing keys**: Still ADD them (completeness required) 1. **Missing keys**: Still ADD them (completeness required)
@ -254,7 +264,7 @@ jobs:
### Step 2.3: Process DELETE Operations ### Step 2.3: Process DELETE Operations
For extra keys reported by i18n:check: For extra keys reported by i18n:check:
- Run: `pnpm --dir web run i18n:check --auto-remove` - Run: `pnpm --dir ${{ github.workspace }}/web run i18n:check --auto-remove`
- Or manually remove from target language JSON files - Or manually remove from target language JSON files
## Translation Guidelines ## Translation Guidelines
@ -282,7 +292,7 @@ jobs:
### Step 3.1: Run Lint Fix (IMPORTANT!) ### Step 3.1: Run Lint Fix (IMPORTANT!)
```bash ```bash
pnpm --dir web lint:fix --quiet -- 'i18n/**/*.json' pnpm --dir ${{ github.workspace }}/web lint:fix --quiet -- 'i18n/**/*.json'
``` ```
This ensures: This ensures:
- JSON keys are sorted alphabetically (jsonc/sort-keys rule) - JSON keys are sorted alphabetically (jsonc/sort-keys rule)
@ -291,7 +301,7 @@ jobs:
### Step 3.2: Run Final i18n Check ### Step 3.2: Run Final i18n Check
```bash ```bash
pnpm --dir web run i18n:check pnpm --dir ${{ github.workspace }}/web run i18n:check
``` ```
### Step 3.3: Fix Any Remaining Issues ### Step 3.3: Fix Any Remaining Issues
@ -342,39 +352,45 @@ jobs:
### Step 4.1: Check for changes ### Step 4.1: Check for changes
```bash ```bash
git status --porcelain git -C ${{ github.workspace }} status --porcelain
``` ```
If there are changes: If there are changes:
### Step 4.2: Create a new branch and commit ### Step 4.2: Create a new branch and commit
Run these git commands ONE BY ONE (not combined with &&): Run these git commands ONE BY ONE (not combined with &&).
**IMPORTANT**: Do NOT use `$()` command substitution. Use two separate commands:
1. Create branch: 1. First, get the timestamp:
```bash ```bash
git checkout -b "chore/i18n-sync-$(date +%Y%m%d-%H%M%S)" date +%Y%m%d-%H%M%S
```
(Note the output, e.g., "20260115-143052")
2. Then create branch using the timestamp value:
```bash
git -C ${{ github.workspace }} checkout -b chore/i18n-sync-20260115-143052
```
(Replace "20260115-143052" with the actual timestamp from step 1)
3. Stage changes:
```bash
git -C ${{ github.workspace }} add web/i18n/
``` ```
2. Stage changes: 4. Commit:
```bash ```bash
git add web/i18n/ git -C ${{ github.workspace }} commit -m "chore(i18n): sync translations with en-US - Mode: ${{ steps.detect_changes.outputs.SYNC_MODE }}"
``` ```
3. Commit (use heredoc for multi-line message): 5. Push:
```bash ```bash
git commit -m "chore(i18n): sync translations with en-US - Mode: ${{ steps.detect_changes.outputs.SYNC_MODE }}" git -C ${{ github.workspace }} push origin HEAD
```
4. Push:
```bash
git push origin HEAD
``` ```
### Step 4.3: Create Pull Request ### Step 4.3: Create Pull Request
```bash ```bash
gh pr create \ gh pr create --repo ${{ github.repository }} --title "chore(i18n): sync translations with en-US" --body "## Summary
--title "chore(i18n): sync translations with en-US" \
--body "## Summary
This PR was automatically generated to sync i18n translation files. This PR was automatically generated to sync i18n translation files.
@ -386,10 +402,9 @@ jobs:
- [x] \`i18n:check\` passed - [x] \`i18n:check\` passed
- [x] \`lint:fix\` applied - [x] \`lint:fix\` applied
🤖 Generated with Claude Code GitHub Action" \ 🤖 Generated with Claude Code GitHub Action" --base main
--base main
``` ```
claude_args: | claude_args: |
--max-turns 150 --max-turns 150
--allowedTools "Read,Write,Edit,Bash(git *),Bash(git:*),Bash(gh *),Bash(gh:*),Bash(pnpm *),Bash(pnpm:*),Glob,Grep" --allowedTools "Read,Write,Edit,Bash(git *),Bash(git:*),Bash(gh *),Bash(gh:*),Bash(pnpm *),Bash(pnpm:*),Bash(date *),Bash(date:*),Glob,Grep"