-
Notifications
You must be signed in to change notification settings - Fork 0
78 lines (69 loc) · 2.24 KB
/
ci.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
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