Skip to content

Prosemirror 中文翻译 #34

Prosemirror 中文翻译

Prosemirror 中文翻译 #34

Workflow file for this run

name: Prosemirror 中文翻译
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 0' # 每周日的午夜
jobs:
Build_and_Publish:
runs-on: ubuntu-latest
steps:
- name: 检出当前仓库
uses: actions/checkout@v3
with:
ref: main
persist-credentials: true
- name: 设置 Git
run: |
git config --global user.name 'Xheldon[bot]'
git config --global user.email '[email protected]'
- name: 检出 Prosemirror/website 仓库
run: |
git clone https://github.com/ProseMirror/website.git
- name: 检查是否有更新
id: check_commits
run: |
cd website
git fetch
NEW_COMMIT=$(git rev-parse HEAD)
cd ..
if [ -f last-commit.txt ]; then
OLD_COMMIT=$(cat last-commit.txt)
else
OLD_COMMIT=""
fi
echo "new_commit=$NEW_COMMIT" >> $GITHUB_ENV
echo "old_commit=$OLD_COMMIT" >> $GITHUB_ENV
if [[ "$NEW_COMMIT" != "$OLD_COMMIT" ]]; then
echo "每周检查发现新的提交"
echo "new_commits=true" >> $GITHUB_ENV
echo "$NEW_COMMIT" > last-commit.txt
else
if [[ ${{ github.event_name }} == 'workflow_dispatch' ]]; then
echo "手动触发更新"
echo "new_commits=true" >> $GITHUB_ENV
else
echo "没有新的提交。"
echo "new_commits=false" >> $GITHUB_ENV
fi
fi
- name: 安装依赖
if: env.new_commits == 'true'
run: |
cd website
npm install
cat ../append-head.html >> templates/head.html
make
- name: 构建中文翻译
if: env.new_commits == 'true'
run: |
npm install
node index.js
- name: 推送到 gp 分支
if: env.new_commits == 'true'
run: |
git checkout -b temp
rm -rf public
mkdir -p public && cp vercel.sh public && cp -R website/public/* public
git add .
git commit -m "更新文档[bot]"
git push -f https://Xheldon:${{ secrets.GIT_TOKEN }}@github.com/${{ github.repository }} temp:main