Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 36 additions & 14 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,43 @@
name: Deploy VitePress

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

permissions:
contents: write
contents: read
pages: write
id-token: write # deploy-pages 经 OIDC 验证部署来源,必需

# 同一时间只跑一个部署,排队中的不取消,保证最新一次一定部署成功
concurrency:
group: pages
cancel-in-progress: false

jobs:
deploy:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
fetch-depth: 0 # lastUpdated: true 需要完整 git 历史

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: pnpm

- name: Install dependencies
run: pnpm install --frozen-lockfile

Expand All @@ -41,14 +50,27 @@ jobs:
vitepress-build-${{ runner.os }}-
vitepress-build-

- name: Setup Pages
uses: actions/configure-pages@v5

- name: Build
run: pnpm build
env:
NODE_OPTIONS: --max-old-space-size=6144
NODE_OPTIONS: --max-old-space-size=6144 # 分卷并行构建仍需较大堆,防 OOM
BUILD_CONCURRENCY: 8

- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./site/.vitepress/dist
path: site/.vitepress/dist

deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
1 change: 0 additions & 1 deletion README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ See [changelogs/](changelogs/) for full release history.
|--------|---------|--------|
| `main` | Primary development branch | Active |
| `archive/legacy_20260415` | Pre-restructuring archive | Read-only |
| `gh-pages` | Auto-deployed documentation site | Auto-generated |

</details>

Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ cmake -S code/examples/chapter05/06_array_vs_stdarray -B build && cmake --build
|------|------|------|
| `main` | 主开发分支 | Active |
| `archive/legacy_20260415` | 重构前存档 | Read-only |
| `gh-pages` | 自动部署的文档站 | Auto-generated |

</details>

Expand Down
Loading