mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-24 18:50:56 +08:00
* ci(i18n): change auto i18n workflow to run weekly Update the workflow to run on a weekly schedule instead of on pull request events. Also simplify the workflow by using yarn for dependency management and create a PR for changes instead of committing directly to the branch. * ci(github-actions): improve workflow step names with emojis Use emojis in step names to enhance readability and visual scanning of workflow logs * ci(workflow): prevent committing package.json and yarn.lock changes in i18n workflow
94 lines
3.1 KiB
YAML
94 lines
3.1 KiB
YAML
name: Auto I18N Weekly
|
|
|
|
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 Sunday.
|
|
# This corresponds to 08:00 AM UTC+8 (Beijing time) every Sunday.
|
|
- cron: "0 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@v5
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: 📦 Setting Node.js
|
|
uses: actions/setup-node@v6
|
|
with:
|
|
node-version: 22
|
|
|
|
- name: 📦 Install corepack
|
|
run: corepack enable && corepack prepare yarn@4.9.1 --activate
|
|
|
|
- name: 📂 Get yarn cache directory path
|
|
id: yarn-cache-dir-path
|
|
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
|
|
|
|
- name: 💾 Cache yarn dependencies
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
${{ steps.yarn-cache-dir-path.outputs.dir }}
|
|
node_modules
|
|
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-yarn-
|
|
|
|
- name: 📦 Install dependencies
|
|
run: |
|
|
yarn install
|
|
|
|
- name: 🏃♀️ Translate
|
|
run: yarn sync:i18n && yarn auto:i18n
|
|
|
|
- name: 🔍 Format
|
|
run: yarn format
|
|
|
|
- name: 🔍 Check for changes
|
|
id: git_status
|
|
run: |
|
|
# Check if there are any uncommitted changes
|
|
git reset -- package.json yarn.lock # 不提交 package.json 和 yarn.lock 的更改
|
|
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@v6
|
|
with:
|
|
token: ${{ secrets.GITHUB_TOKEN }} # Use the built-in GITHUB_TOKEN for bot actions
|
|
commit-message: "feat(bot): Weekly automated script run"
|
|
title: "🤖 Weekly Automated Update: ${{ env.CURRENT_DATE }}"
|
|
body: |
|
|
This PR includes changes generated by the weekly auto i18n.
|
|
Review the changes before merging.
|
|
|
|
---
|
|
_Generated by the automated weekly workflow_
|
|
branch: "auto-i18n-weekly-${{ 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."
|