mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-02-21 18:14:45 +08:00
### What this PR does Before this PR: - Auto i18n workflow runs weekly on Sundays at 00:00 UTC - Workflow name was "Auto I18N Weekly" After this PR: - Auto i18n workflow runs daily at 00:00 UTC - Workflow name is "Auto I18N Daily" ### Why we need it and why it was done in this way The following tradeoffs were made: - More frequent syncs mean more PR noise, but translations stay more up-to-date The following alternatives were considered: - Keeping weekly schedule: translations may lag behind source changes - Running on weekdays only: skipped in favor of daily for simplicity ### Breaking changes None ### Special notes for your reviewer None ### Checklist - [x] PR: The PR description is expressive enough and will help future contributors - [x] Code: [Write code that humans can understand](https://en.wikiquote.org/wiki/Martin_Fowler#code-for-humans) and [Keep it simple](https://en.wikipedia.org/wiki/KISS_principle) - [x] Refactor: You have [left the code cleaner than you found it (Boy Scout Rule)](https://learning.oreilly.com/library/view/97-things-every/9780596809515/ch08.html) - [x] Upgrade: Impact of this change on upgrade flows was considered and addressed if required - [x] Documentation: A [user-guide update](https://docs.cherry-ai.com) was considered and is present (link) or not required. You want a user-guide update if it's a user facing feature. ### Release note ```release-note Change auto-i18n workflow schedule from weekly to daily for more frequent translation synchronization. ``` 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
120 lines
4.0 KiB
YAML
120 lines
4.0 KiB
YAML
name: Auto I18N Daily
|
|
|
|
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:
|
|
schedule:
|
|
# Runs at 00:00 UTC every day.
|
|
# This corresponds to 08:00 AM UTC+8 (Beijing time) every day.
|
|
- cron: "0 0 * * *"
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
auto-i18n:
|
|
runs-on: ubuntu-latest
|
|
name: Auto I18N
|
|
permissions:
|
|
contents: write
|
|
pull-requests: write
|
|
|
|
steps:
|
|
- name: 🐈⬛ Checkout
|
|
uses: actions/checkout@v6
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: 📦 Setting Node.js
|
|
uses: actions/setup-node@v6
|
|
with:
|
|
node-version: 22
|
|
|
|
- name: 📦 Install pnpm
|
|
uses: pnpm/action-setup@v4
|
|
|
|
- name: 📂 Get pnpm store directory
|
|
id: pnpm-cache
|
|
shell: bash
|
|
run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
|
|
|
|
- name: 💾 Cache pnpm dependencies
|
|
uses: actions/cache@v5
|
|
with:
|
|
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
|
|
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-pnpm-
|
|
|
|
- name: 📦 Install dependencies
|
|
run: |
|
|
pnpm install
|
|
|
|
- name: 🏃♀️ Translate
|
|
run: pnpm i18n:sync && pnpm i18n:translate
|
|
|
|
- name: 🔍 Format
|
|
run: pnpm format
|
|
|
|
- name: 🔍 Check for changes
|
|
id: git_status
|
|
run: |
|
|
# Check if there are any uncommitted changes
|
|
git reset -- package.json pnpm-lock.yaml # 不提交 package.json 和 pnpm-lock.yaml 的更改
|
|
git diff --exit-code --quiet || echo "::set-output name=has_changes::true"
|
|
git status --porcelain
|
|
|
|
- name: 📅 Set current date for PR title
|
|
id: set_date
|
|
run: echo "CURRENT_DATE=$(date +'%b %d, %Y')" >> $GITHUB_ENV # e.g., "Jun 06, 2024"
|
|
|
|
- name: 🚀 Create Pull Request if changes exist
|
|
if: steps.git_status.outputs.has_changes == 'true'
|
|
uses: peter-evans/create-pull-request@v8
|
|
with:
|
|
token: ${{ secrets.GITHUB_TOKEN }} # Use the built-in GITHUB_TOKEN for bot actions
|
|
commit-message: "feat(bot): Daily automated script run"
|
|
title: "🤖 Daily Auto I18N Sync: ${{ env.CURRENT_DATE }}"
|
|
body: |
|
|
This PR includes changes generated by the daily auto i18n.
|
|
Review the changes before merging.
|
|
|
|
---
|
|
_Generated by the automated daily workflow_
|
|
branch: "auto-i18n-daily-${{ github.run_id }}" # Unique branch name
|
|
base: "main" # Or 'develop', set your base branch
|
|
delete-branch: true # Delete the branch after merging or closing the PR
|
|
|
|
- name: 📢 Notify if no changes
|
|
if: steps.git_status.outputs.has_changes != 'true'
|
|
run: echo "Bot script ran, but no changes were detected. No PR created."
|
|
|
|
- name: Send failure notification to Feishu
|
|
if: always() && (failure() || cancelled())
|
|
shell: bash
|
|
env:
|
|
FEISHU_WEBHOOK_URL: ${{ secrets.FEISHU_WEBHOOK_URL }}
|
|
FEISHU_WEBHOOK_SECRET: ${{ secrets.FEISHU_WEBHOOK_SECRET }}
|
|
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
|
JOB_STATUS: ${{ job.status }}
|
|
run: |
|
|
# Determine status and color
|
|
if [ "$JOB_STATUS" = "cancelled" ]; then
|
|
STATUS_TEXT="已取消"
|
|
COLOR="orange"
|
|
else
|
|
STATUS_TEXT="失败"
|
|
COLOR="red"
|
|
fi
|
|
|
|
# Build description using printf
|
|
DESCRIPTION=$(printf "**状态:** %s\n\n**工作流:** [查看详情](%s)" "$STATUS_TEXT" "$RUN_URL")
|
|
|
|
# Send notification
|
|
pnpm tsx scripts/feishu-notify.ts send \
|
|
-t "自动国际化${STATUS_TEXT}" \
|
|
-d "$DESCRIPTION" \
|
|
-c "${COLOR}"
|