forked from unjs/unplugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 新增 i18n.yml 文件,配置国际化工作流 - 工作流触发条件包括 i18n 分支推送和 docs 目录下的 PR - 步骤包括检出代码、设置 Node.js 和 Deno 环境 - 使用 ai-markdown-translator 工具翻译文档
- Loading branch information
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
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 |