Skip to content

Commit

Permalink
ci(i18n): 添加国际化工作流
Browse files Browse the repository at this point in the history
- 新增 i18n.yml 文件,配置国际化工作流
- 工作流触发条件包括 i18n 分支推送和 docs 目录下的 PR
- 步骤包括检出代码、设置 Node.js 和 Deno 环境
- 使用 ai-markdown-translator 工具翻译文档
  • Loading branch information
h7ml committed Dec 17, 2024
1 parent aec274c commit 49a4762
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/i18n.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: i18n

on:
push:
branches:
- i18n
pull_request:
paths:
- docs/**

jobs:
i18n:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- run: corepack enable
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'
- uses: denoland/setup-deno@v2
with:
deno-version: v2.x

- run: npx ai-markdown-translator -i ./docs -e md -l chinese

- name: Commit and push changes if any
run: |
if git diff --exit-code; then
echo "No changes to commit"
else
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git config advice.ignoredHook false
git commit -am "i18n: translate docs"
git push -f origin i18n
fi
- name: Create or update pull request
run: |
pr_exists=$(gh pr list --state open --head i18n | wc -l)
if [ "$pr_exists" -eq 0 ]; then
gh pr create --title "i18n: translate docs" --body "i18n: translate docs"
else
gh pr edit --title "i18n: translate docs" --body "i18n: translate docs"
fi

0 comments on commit 49a4762

Please sign in to comment.