@@ -33,35 +33,29 @@ jobs:
33
33
ref : docs
34
34
path : mkdocs
35
35
36
- # 3️⃣ 移动竞赛专属 README 到 docs 结构中
36
+ # 3️⃣ 移动竞赛 README 到 mkdocs/ docs 结构中
37
37
- name : Move contest files
38
38
run : |
39
39
cp main/solution/CONTEST_README.md mkdocs/docs/contest.md
40
40
cp main/solution/CONTEST_README_EN.md mkdocs/docs-en/contest.md
41
41
42
- # 4️⃣ 配置 Git 用户信息(后续 commit 缓存用)
43
- - name : Configure Git Credentials
44
- run : |
45
- git config user.name github-actions[bot]
46
- git config user.email 41898282+github-actions[bot]@users.noreply.github.com
47
-
48
- # 5️⃣ 安装 Python
42
+ # 4️⃣ 安装 Python
49
43
- uses : actions/setup-python@v5
50
44
with :
51
45
python-version : 3.x
52
46
53
- # 6️⃣ 设置缓存 Key(按周)
47
+ # 5️⃣ 设置缓存 Key(按周)
54
48
- run : echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
55
49
56
- # 7️⃣ 缓存 mkdocs-material 依赖缓存
50
+ # 6️⃣ 缓存 mkdocs-material 的编译产物
57
51
- uses : actions/cache@v4
58
52
with :
59
53
key : mkdocs-material-${{ env.cache_id }}
60
54
path : mkdocs/.cache
61
55
restore-keys : |
62
56
mkdocs-material-
63
57
64
- # 8️⃣ 安装依赖
58
+ # 7️⃣ 安装依赖
65
59
- name : Install dependencies
66
60
working-directory : mkdocs
67
61
run : |
@@ -70,11 +64,11 @@ jobs:
70
64
python3 -m pip install "mkdocs-material[imaging]"
71
65
sudo apt-get install pngquant
72
66
73
- # 9️⃣ 设置 API token 环境变量
67
+ # 8️⃣ 设置 API token 环境变量
74
68
- name : Set MKDOCS_API_KEYS environment variable
75
69
run : echo "MKDOCS_API_KEYS=${{ secrets.MKDOCS_API_KEYS }}" >> $GITHUB_ENV
76
70
77
- # 🔟 执行构建(main.py 中访问的是 main/ 下的内容)
71
+ # 9️⃣ 执行构建
78
72
- name : Build site
79
73
working-directory : mkdocs
80
74
run : |
@@ -83,24 +77,28 @@ jobs:
83
77
mkdocs build -f mkdocs-en.yml
84
78
echo "leetcode.doocs.org" > ./site/CNAME
85
79
86
- # 1️⃣1️⃣ 提交缓存(包括 path-map.json 和 page-authors.json)回 docs 分支
80
+ # 🔟 提交缓存到 docs 分支
87
81
- name : Commit cache files back to docs branch
88
82
working-directory : mkdocs
89
83
run : |
90
- git config user.name "github-actions[bot]"
91
- git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
92
-
93
- git add .cache/path-map.json
94
- git add .cache/plugin/git-committers/page-authors.json
95
-
96
- if git diff --cached --quiet; then
97
- echo "No changes to commit"
84
+ if [ -d ".git" ]; then
85
+ git config user.name "github-actions[bot]"
86
+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
87
+
88
+ git add .cache/path-map.json || true
89
+ git add .cache/plugin/git-committers/page-authors.json || true
90
+
91
+ if git diff --cached --quiet; then
92
+ echo "No changes to commit"
93
+ else
94
+ git commit -m "chore: update committers and path map [bot]"
95
+ git push origin HEAD:docs
96
+ fi
98
97
else
99
- git commit -m "chore: update committers and path map [bot]"
100
- git push origin HEAD:docs
101
- fi
98
+ echo "::error ::Git directory not found in mkdocs/. Are you sure checkout was successful?"
99
+ exit 1
102
100
103
- # 1️⃣2️⃣ 上传站点构建产物
101
+ # 1️⃣1️⃣ 上传构建产物
104
102
- name : Upload artifact
105
103
uses : actions/upload-pages-artifact@v3
106
104
with :
0 commit comments