♻️ refactor: implement config-based update system with version compatibility control #1371
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Auto I18N | |
| env: | |
| TRANSLATION_API_KEY: ${{ secrets.TRANSLATE_API_KEY }} | |
| TRANSLATION_MODEL: ${{ vars.AUTO_I18N_MODEL || 'deepseek/deepseek-v3.1'}} | |
| TRANSLATION_BASE_URL: ${{ vars.AUTO_I18N_BASE_URL || 'https://api.ppinfra.com/openai'}} | |
| TRANSLATION_BASE_LOCALE: ${{ vars.AUTO_I18N_BASE_LOCALE || 'en-us'}} | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| workflow_dispatch: | |
| jobs: | |
| auto-i18n: | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'workflow_dispatch' || github.event.pull_request.head.repo.full_name == 'CherryHQ/cherry-studio' | |
| name: Auto I18N | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - name: 🐈⬛ Checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| ref: ${{ github.event.pull_request.head.ref }} | |
| - name: 📦 Setting Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 20 | |
| package-manager-cache: false | |
| - name: 📦 Install dependencies in isolated directory | |
| run: | | |
| # 在临时目录安装依赖 | |
| mkdir -p /tmp/translation-deps | |
| cd /tmp/translation-deps | |
| echo '{"dependencies": {"@cherrystudio/openai": "^6.5.0", "cli-progress": "^3.12.0", "tsx": "^4.20.3", "@biomejs/biome": "2.2.4"}}' > package.json | |
| npm install --no-package-lock | |
| # 设置 NODE_PATH 让项目能找到这些依赖 | |
| echo "NODE_PATH=/tmp/translation-deps/node_modules" >> $GITHUB_ENV | |
| - name: 🏃♀️ Translate | |
| run: npx tsx scripts/sync-i18n.ts && npx tsx scripts/auto-translate-i18n.ts | |
| - name: 🔍 Format | |
| run: cd /tmp/translation-deps && npx biome format --config-path /home/runner/work/cherry-studio/cherry-studio/biome.jsonc --write /home/runner/work/cherry-studio/cherry-studio/src/renderer/src/i18n/ | |
| - name: 🔄 Commit changes | |
| run: | | |
| git config --local user.email "[email protected]" | |
| git config --local user.name "GitHub Action" | |
| git add . | |
| git reset -- package.json yarn.lock # 不提交 package.json 和 yarn.lock 的更改 | |
| if git diff --cached --quiet; then | |
| echo "No changes to commit" | |
| else | |
| git commit -m "fix(i18n): Auto update translations for PR #${{ github.event.pull_request.number }}" | |
| fi | |
| - name: 🚀 Push changes | |
| uses: ad-m/github-push-action@master | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| branch: ${{ github.event.pull_request.head.ref }} |