Skip to content

Commit 9e89348

Browse files
committed
ci: 添加翻译 SystemPrompts 到中文的工作流
- 新增 GitHub Actions 工作流,用于将 SystemPrompts 目录中的 Markdown 文件翻译成中文 - 工作流手动触发时执行以下步骤: - 检出指定分支 - 安装 Node.js 环境 - 使用 ai-markdown-translator 工具进行翻译 - 提交翻译后的文件到仓库 - 清理旧的 workflow 运行记录 - 通过环境变量和 secrets 配置 API 密钥和 GitHub 令牌
1 parent 54d5fb8 commit 9e89348

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: 翻译SystemPrompts到中文
2+
3+
on:
4+
# 允许手动触发工作流
5+
workflow_dispatch:
6+
7+
jobs:
8+
translate:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
# 检出指定分支
13+
- name: 检出仓库
14+
uses: actions/checkout@v3
15+
with:
16+
ref: zh/SystemPrompts
17+
18+
# 安装Node.js环境
19+
- name: 设置Node.js环境
20+
uses: actions/setup-node@v3
21+
with:
22+
node-version: '20'
23+
24+
# 执行翻译任务
25+
- name: 翻译Markdown文件
26+
run: |
27+
npx ai-markdown-translator -i ./SystemPrompts/ -l 中文 --openai-url https://api.302.ai/v1/chat/completions --api-key ${{ secrets.OPENAI_API_KEY_302AI }} --model claude-3-7-sonnet-latest -e md --log
28+
29+
# 提交更新
30+
- name: 提交翻译后的文件到仓库
31+
if: success() || failure() # 无论之前步骤成功与否都尝试提交
32+
continue-on-error: true # 允许提交失败但继续执行
33+
run: |
34+
git config --local user.email "[email protected]"
35+
git config --local user.name "GitHub Action"
36+
git config advice.ignoredHook false
37+
git add ./SystemPrompts/
38+
git add ./log.md
39+
git commit -m "翻译更新: SystemPrompts目录 $(date +%Y-%m-%d)" || echo "没有需要提交的更改"
40+
git push origin zh/SystemPrompts
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
44+
# 清理工作
45+
- name: 清理旧的workflow运行记录
46+
if: always() # 总是执行清理步骤
47+
continue-on-error: true # 允许清理失败但不影响整体状态
48+
uses: Mattraks/delete-workflow-runs@v2
49+
with:
50+
token: ${{ github.token }}
51+
repository: ${{ github.repository }}
52+
retain_days: 10
53+
keep_minimum_runs: 6

0 commit comments

Comments
 (0)