From c0641801d8c5f9a5ad870f414b443275c99346eb Mon Sep 17 00:00:00 2001 From: Charliechen114514 <725610365@qq.com> Date: Tue, 23 Jun 2026 09:34:13 +0800 Subject: [PATCH] optimized: better page deplotments --- .github/workflows/deploy.yml | 50 ++++++++++++++++++++++++++---------- README.en.md | 1 - README.md | 1 - 3 files changed, 36 insertions(+), 16 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 62e0bea67..988ca2e6c 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,5 +1,7 @@ name: Deploy VitePress +# 推到 main 即自动构建,产物作为一次性 artifact 部署到 GitHub Pages(不提交进任何分支)。 +# 首次使用前:仓库 Settings → Pages → Source 必须选「GitHub Actions」(非 Deploy from a branch)。 on: push: branches: @@ -7,28 +9,35 @@ on: 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 @@ -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 diff --git a/README.en.md b/README.en.md index e511eeaf7..b15578c2c 100644 --- a/README.en.md +++ b/README.en.md @@ -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 | diff --git a/README.md b/README.md index 61a5a09f6..701b98f16 100644 --- a/README.md +++ b/README.md @@ -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 |