-
-
Notifications
You must be signed in to change notification settings - Fork 118
115 lines (95 loc) · 3.48 KB
/
SyncDoc.yml
File metadata and controls
115 lines (95 loc) · 3.48 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: Sync Readme Files
on:
push:
paths:
- "**/CHANGELOG.md" # 脚本更新日志
- "**/README.md" # 脚本介绍文件
- "docs/ScriptsPath.json" # 脚本列表
workflow_dispatch:
jobs:
run-python:
if: ${{ github.event.commits[0].committer.username != 'ChinaGodBot' }}
runs-on: ubuntu-latest
env:
TZ: Asia/Shanghai
steps:
- name: 检出代码
uses: actions/checkout@v6
with:
token: ${{ secrets.QWY_SYNC_BOT_TOKEN }}
fetch-depth: 0 #检查时间用.
- name: 设置 Node.js
uses: actions/setup-node@v6
with:
node-version: "lts/*"
- name: 设置 Python
uses: actions/setup-python@v6.2.0
with:
python-version: "3.12.4"
- name: pip
run: pip install -r utils/requirements.txt
- name: npm
run: npm install
- name: 检查新脚本
run: python utils/script-import-sync.py
env:
GFU: ${{ secrets.GFU }}
GFP: ${{ secrets.GFP }}
GREASYFORK_TOTP_SECRET: ${{ secrets.GREASYFORK_TOTP_SECRET }}
#- name: 相关脚本
# run: python utils/update_related_scripts.py
#- name: 所有脚本
# run: python utils/update_related_all_scripts.py
- name: 导航栏
run: python utils/navigation.py
- name: 变更日志
run: python utils/merge_change_history.py
- name: 刷新仓库自述中的脚本列表
run: python utils/update_scripts_list.py
- name: 翻译仓库自述
run: python utils/translate_force_chinese_to_lang.py
- name: 修复其他语言readme中的相对路径
run: python utils/fix_toc.py
# `徽章信息` `帮助信息` 需要从修复toc之后提取脚本列表标记点.
- name: 徽章信息
run: python utils/update_shields.py
- name: 帮助信息
run: python utils/update_help.py
- name: 翻译脚本自述
run: python utils/translate_chinese_to_filelang.py
- name: 设置机器人提交
run: |
gpg --batch --import <(echo "${{ secrets.GPG_PRIVATE_KEY }}")
git config --global commit.gpgsign true
git config --global user.name 'ChinaGodBot'
git config --global user.email "${{ secrets.GPG_PRIVATE_EMAIL }}"
git config --global user.signingkey "${{ secrets.GPG_PRIVATE_ID }}"
- name: 提交和推送更改
run: |
# 在github action中安装依赖有时候会修改[package-lock.json], 恢复下,不在commit中对无关文件进行修改.
git restore package-lock.json
git pull
git add .
COMMIT_MESSAGE="docs(sync): 🤖 同步"
# docs/[lang]/readme.md
if git status --short | grep -q "docs/.*/README.md"; then
if git status --short | grep -q "README_"; then
COMMIT_MESSAGE+=" [\`docs/[lang]/README.md\`]"
else
COMMIT_MESSAGE+=" [\`[lang]/README.md\`]"
fi
fi
# 脚本自述
if git status --short | grep -q "README_"; then
if git status --short | grep -q "docs/.*/README.md"; then
COMMIT_MESSAGE+=" [\`[script]/README_[lang].md\`]"
else
COMMIT_MESSAGE+=" [\`README_[lang].md\`]"
fi
fi
git commit -n -m "$COMMIT_MESSAGE" || true
git push
if [ $? -ne 0 ]; then
git pull --rebase
git push
fi