-
Notifications
You must be signed in to change notification settings - Fork 19
76 lines (64 loc) · 2.14 KB
/
Copy pathdeploy.yml
File metadata and controls
76 lines (64 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
name: Deploy VitePress
# 推到 main 即自动构建,产物作为一次性 artifact 部署到 GitHub Pages(不提交进任何分支)。
# 首次使用前:仓库 Settings → Pages → Source 必须选「GitHub Actions」(非 Deploy from a branch)。
on:
push:
branches:
- main
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write # deploy-pages 经 OIDC 验证部署来源,必需
# 同一时间只跑一个部署,排队中的不取消,保证最新一次一定部署成功
concurrency:
group: pages
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
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
- name: Restore build cache
uses: actions/cache@v4
with:
path: site/.vitepress/.build-cache
key: vitepress-build-${{ runner.os }}-${{ hashFiles('documents/**', 'site/.vitepress/config/**', 'site/.vitepress/plugins/**', 'site/.vitepress/public/**', 'site/.vitepress/theme/**', 'scripts/build.ts', 'package.json', 'pnpm-lock.yaml') }}
restore-keys: |
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 # 分卷并行构建仍需较大堆,防 OOM
BUILD_CONCURRENCY: 8
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
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