Skip to content

Commit dd5eeae

Browse files
optimized: better page deplotments (#78)
1 parent 97f0b1f commit dd5eeae

3 files changed

Lines changed: 36 additions & 16 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,43 @@
11
name: Deploy VitePress
22

3+
# 推到 main 即自动构建,产物作为一次性 artifact 部署到 GitHub Pages(不提交进任何分支)。
4+
# 首次使用前:仓库 Settings → Pages → Source 必须选「GitHub Actions」(非 Deploy from a branch)。
35
on:
46
push:
57
branches:
68
- main
79
workflow_dispatch:
810

911
permissions:
10-
contents: write
12+
contents: read
13+
pages: write
14+
id-token: write # deploy-pages 经 OIDC 验证部署来源,必需
15+
16+
# 同一时间只跑一个部署,排队中的不取消,保证最新一次一定部署成功
17+
concurrency:
18+
group: pages
19+
cancel-in-progress: false
1120

1221
jobs:
13-
deploy:
22+
build:
1423
runs-on: ubuntu-latest
15-
1624
steps:
1725
- name: Checkout
1826
uses: actions/checkout@v4
1927
with:
20-
fetch-depth: 0
21-
22-
- name: Setup Node.js
23-
uses: actions/setup-node@v4
24-
with:
25-
node-version: '22'
28+
fetch-depth: 0 # lastUpdated: true 需要完整 git 历史
2629

2730
- name: Setup pnpm
2831
uses: pnpm/action-setup@v4
2932
with:
3033
version: 10
3134

35+
- name: Setup Node.js
36+
uses: actions/setup-node@v4
37+
with:
38+
node-version: '22'
39+
cache: pnpm
40+
3241
- name: Install dependencies
3342
run: pnpm install --frozen-lockfile
3443

@@ -41,14 +50,27 @@ jobs:
4150
vitepress-build-${{ runner.os }}-
4251
vitepress-build-
4352
53+
- name: Setup Pages
54+
uses: actions/configure-pages@v5
55+
4456
- name: Build
4557
run: pnpm build
4658
env:
47-
NODE_OPTIONS: --max-old-space-size=6144
59+
NODE_OPTIONS: --max-old-space-size=6144 # 分卷并行构建仍需较大堆,防 OOM
4860
BUILD_CONCURRENCY: 8
4961

50-
- name: Deploy to GitHub Pages
51-
uses: peaceiris/actions-gh-pages@v4
62+
- name: Upload artifact
63+
uses: actions/upload-pages-artifact@v3
5264
with:
53-
github_token: ${{ secrets.GITHUB_TOKEN }}
54-
publish_dir: ./site/.vitepress/dist
65+
path: site/.vitepress/dist
66+
67+
deploy:
68+
needs: build
69+
runs-on: ubuntu-latest
70+
environment:
71+
name: github-pages
72+
url: ${{ steps.deployment.outputs.page_url }}
73+
steps:
74+
- name: Deploy to GitHub Pages
75+
id: deployment
76+
uses: actions/deploy-pages@v4

README.en.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ See [changelogs/](changelogs/) for full release history.
158158
|--------|---------|--------|
159159
| `main` | Primary development branch | Active |
160160
| `archive/legacy_20260415` | Pre-restructuring archive | Read-only |
161-
| `gh-pages` | Auto-deployed documentation site | Auto-generated |
162161

163162
</details>
164163

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ cmake -S code/examples/chapter05/06_array_vs_stdarray -B build && cmake --build
161161
|------|------|------|
162162
| `main` | 主开发分支 | Active |
163163
| `archive/legacy_20260415` | 重构前存档 | Read-only |
164-
| `gh-pages` | 自动部署的文档站 | Auto-generated |
165164

166165
</details>
167166

0 commit comments

Comments
 (0)