ci: fix translate, allow manual dispatch (#30505)

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Stephen Zhou 2026-01-04 16:34:23 +08:00 committed by GitHub
parent d4baf078f7
commit 9aaa08e19f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -5,6 +5,7 @@ on:
branches: [main] branches: [main]
paths: paths:
- 'web/i18n/en-US/*.json' - 'web/i18n/en-US/*.json'
workflow_dispatch:
permissions: permissions:
contents: write contents: write
@ -18,7 +19,8 @@ jobs:
run: run:
working-directory: web working-directory: web
steps: steps:
- uses: actions/checkout@v6 # Keep use old checkout action version for https://github.com/peter-evans/create-pull-request/issues/4272
- uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@ -26,21 +28,28 @@ jobs:
- name: Check for file changes in i18n/en-US - name: Check for file changes in i18n/en-US
id: check_files id: check_files
run: | run: |
git fetch origin "${{ github.event.before }}" || true # Skip check for manual trigger, translate all files
git fetch origin "${{ github.sha }}" || true if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
changed_files=$(git diff --name-only "${{ github.event.before }}" "${{ github.sha }}" -- 'i18n/en-US/*.json')
echo "Changed files: $changed_files"
if [ -n "$changed_files" ]; then
echo "FILES_CHANGED=true" >> $GITHUB_ENV echo "FILES_CHANGED=true" >> $GITHUB_ENV
file_args="" echo "FILE_ARGS=" >> $GITHUB_ENV
for file in $changed_files; do echo "Manual trigger: translating all files"
filename=$(basename "$file" .json)
file_args="$file_args --file $filename"
done
echo "FILE_ARGS=$file_args" >> $GITHUB_ENV
echo "File arguments: $file_args"
else else
echo "FILES_CHANGED=false" >> $GITHUB_ENV git fetch origin "${{ github.event.before }}" || true
git fetch origin "${{ github.sha }}" || true
changed_files=$(git diff --name-only "${{ github.event.before }}" "${{ github.sha }}" -- 'i18n/en-US/*.json')
echo "Changed files: $changed_files"
if [ -n "$changed_files" ]; then
echo "FILES_CHANGED=true" >> $GITHUB_ENV
file_args=""
for file in $changed_files; do
filename=$(basename "$file" .json)
file_args="$file_args --file $filename"
done
echo "FILE_ARGS=$file_args" >> $GITHUB_ENV
echo "File arguments: $file_args"
else
echo "FILES_CHANGED=false" >> $GITHUB_ENV
fi
fi fi
- name: Install pnpm - name: Install pnpm