@@ -33,35 +33,29 @@ jobs:
3333 ref : docs
3434 path : mkdocs
3535
36- # 3️⃣ 移动竞赛专属 README 到 docs 结构中
36+ # 3️⃣ 移动竞赛 README 到 mkdocs/ docs 结构中
3737 - name : Move contest files
3838 run : |
3939 cp main/solution/CONTEST_README.md mkdocs/docs/contest.md
4040 cp main/solution/CONTEST_README_EN.md mkdocs/docs-en/contest.md
4141
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
4943 - uses : actions/setup-python@v5
5044 with :
5145 python-version : 3.x
5246
53- # 6️⃣ 设置缓存 Key(按周)
47+ # 5️⃣ 设置缓存 Key(按周)
5448 - run : echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
5549
56- # 7️⃣ 缓存 mkdocs-material 依赖缓存
50+ # 6️⃣ 缓存 mkdocs-material 的编译产物
5751 - uses : actions/cache@v4
5852 with :
5953 key : mkdocs-material-${{ env.cache_id }}
6054 path : mkdocs/.cache
6155 restore-keys : |
6256 mkdocs-material-
6357
64- # 8️⃣ 安装依赖
58+ # 7️⃣ 安装依赖
6559 - name : Install dependencies
6660 working-directory : mkdocs
6761 run : |
@@ -70,11 +64,11 @@ jobs:
7064 python3 -m pip install "mkdocs-material[imaging]"
7165 sudo apt-get install pngquant
7266
73- # 9️⃣ 设置 API token 环境变量
67+ # 8️⃣ 设置 API token 环境变量
7468 - name : Set MKDOCS_API_KEYS environment variable
7569 run : echo "MKDOCS_API_KEYS=${{ secrets.MKDOCS_API_KEYS }}" >> $GITHUB_ENV
7670
77- # 🔟 执行构建(main.py 中访问的是 main/ 下的内容)
71+ # 9️⃣ 执行构建
7872 - name : Build site
7973 working-directory : mkdocs
8074 run : |
@@ -83,24 +77,28 @@ jobs:
8377 mkdocs build -f mkdocs-en.yml
8478 echo "leetcode.doocs.org" > ./site/CNAME
8579
86- # 1️⃣1️⃣ 提交缓存(包括 path-map.json 和 page-authors.json)回 docs 分支
80+ # 🔟 提交缓存到 docs 分支
8781 - name : Commit cache files back to docs branch
8882 working-directory : mkdocs
8983 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
9897 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
102100
103- # 1️⃣2️⃣ 上传站点构建产物
101+ # 1️⃣1️⃣ 上传构建产物
104102 - name : Upload artifact
105103 uses : actions/upload-pages-artifact@v3
106104 with :
0 commit comments