Skip to content

Commit 089e43d

Browse files
committed
chore: update deploy workflow
1 parent 7fc7b5c commit 089e43d

File tree

1 file changed

+5
-19
lines changed

1 file changed

+5
-19
lines changed

.github/workflows/deploy.yml

+5-19
Original file line numberDiff line numberDiff line change
@@ -22,94 +22,80 @@ jobs:
2222
build:
2323
runs-on: ubuntu-latest
2424
steps:
25-
# 1️⃣ 拉取 main 分支(完整历史)
2625
- uses: actions/checkout@v4
2726
with:
2827
fetch-depth: 0
2928

30-
# 2️⃣ 拉取 docs 分支到 mkdocs/(完整历史)
3129
- uses: actions/checkout@v4
3230
with:
3331
ref: docs
3432
path: mkdocs
3533
fetch-depth: 0
3634

37-
# 3️⃣ 同步 docs 分支静态内容到根目录,排除 .git
3835
- name: Sync docs branch content
3936
run: |
4037
rsync -a --remove-source-files --exclude='.git' mkdocs/ ./
4138
rm -rf mkdocs
4239
mv solution/CONTEST_README.md docs/contest.md
4340
mv solution/CONTEST_README_EN.md docs-en/contest.md
4441
45-
# 4️⃣ 配置 Git 身份(备用)
4642
- name: Configure Git Credentials
4743
run: |
4844
git config user.name github-actions[bot]
4945
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
5046
51-
# 5️⃣ 安装 Python
5247
- uses: actions/setup-python@v5
5348
with:
5449
python-version: 3.x
5550

56-
# 6️⃣ 一周一次更新的缓存 key
5751
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
5852

59-
# 7️⃣ 复用 .cache
6053
- uses: actions/cache@v4
6154
with:
6255
key: mkdocs-material-${{ env.cache_id }}
6356
path: .cache
6457
restore-keys: |
6558
mkdocs-material-
6659
67-
# 8️⃣ 安装依赖
6860
- name: Install dependencies
6961
run: |
7062
python3 -m pip install --upgrade pip
7163
python3 -m pip install -r requirements.txt
7264
python3 -m pip install "mkdocs-material[imaging]"
7365
sudo apt-get install -y pngquant
7466
75-
# 9️⃣ 注入 GitHub Token 池
7667
- name: Set MKDOCS_API_KEYS
7768
run: echo "MKDOCS_API_KEYS=${{ secrets.MKDOCS_API_KEYS }}" >> $GITHUB_ENV
7869

79-
# 🔟 生成导航 & 构建站点
8070
- run: |
8171
python3 main.py
8272
mkdocs build -f mkdocs.yml
8373
mkdocs build -f mkdocs-en.yml
8474
85-
# 11️⃣ 生成 CNAME
8675
- name: Generate CNAME
8776
run: echo "leetcode.doocs.org" > ./site/CNAME
88-
89-
# 12️⃣ 独立 clone docs 分支并提交 committer 缓存
77+
9078
- name: Commit committer cache to docs branch
9179
if: github.ref == 'refs/heads/main'
9280
env:
9381
GH_REPO: ${{ github.repository }}
9482
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9583
run: |
96-
CACHE_FILE=".cache/plugin/git-committers/page-authors.json"
84+
CACHE_FILE=".git-committers-cache.json"
9785
if [[ ! -f "$CACHE_FILE" ]]; then
9886
echo "Cache file not found; skip commit."
9987
exit 0
10088
fi
10189
10290
echo "Cloning docs branch ..."
10391
git clone --depth 1 --branch docs "https://x-access-token:${GH_TOKEN}@github.com/${GH_REPO}.git" docs-cache
104-
mkdir -p docs-cache/.cache/plugin/git-committers
105-
cp "$CACHE_FILE" docs-cache/.cache/plugin/git-committers/
92+
cp "$CACHE_FILE" docs-cache/
10693
10794
cd docs-cache
108-
git add .cache/plugin/git-committers/page-authors.json
109-
git commit -m "chore: update page-authors cache [skip ci]" || echo "No changes to commit"
95+
git add .git-committers-cache.json
96+
git commit -m "chore: update committer cache [skip ci]" || echo "No changes to commit"
11097
git push origin docs
11198
112-
# 13️⃣ 上传构建产物
11399
- name: Upload artifact
114100
uses: actions/upload-pages-artifact@v3
115101
with:

0 commit comments

Comments
 (0)