1
- # 构建 VitePress 站点并将其部署到 GitHub Pages 的示例工作流程
2
- #
3
- name : Deploy VitePress site to Pages
4
-
5
- on :
6
- # 在针对 `main` 分支的推送上运行。如果你
7
- # 使用 `master` 分支作为默认分支,请将其更改为 `master`
8
- push :
9
- branches : [main]
10
-
11
- # 允许你从 Actions 选项卡手动运行此工作流程
12
- workflow_dispatch :
13
-
14
- # 设置 GITHUB_TOKEN 的权限,以允许部署到 GitHub Pages
15
- permissions :
16
- contents : read
17
- pages : write
18
- id-token : write
19
-
20
- # 只允许同时进行一次部署,跳过正在运行和最新队列之间的运行队列
21
- # 但是,不要取消正在进行的运行,因为我们希望允许这些生产部署完成
22
- concurrency :
23
- group : pages
24
- cancel-in-progress : false
25
-
26
- jobs :
27
- # 构建工作
28
- build :
29
- runs-on : ubuntu-latest
30
- steps :
31
- - name : Checkout
32
- uses : actions/checkout@v4
33
- with :
34
- fetch-depth : 0 # 如果未启用 lastUpdated,则不需要
35
- # - uses: pnpm/action-setup@v3 # 如果使用 pnpm,请取消此区域注释
36
- # with:
37
- # version: 9
38
- # - uses: oven-sh/setup-bun@v1 # 如果使用 Bun,请取消注释
39
- - name : Setup Node
40
- uses : actions/setup-node@v4
41
- with :
42
- node-version : 20
43
- cache : npm # 或 pnpm / yarn
44
- - name : Setup Pages
45
- uses : actions/configure-pages@v4
46
- - name : Install dependencies
47
- run : npm install --legacy-peer-deps # 修改这行,添加 --legacy-peer-deps 参数
48
- - name : Build with VitePress
49
- run : npm run docs:build # 或 pnpm docs:build / yarn docs:build / bun run docs:build
50
- - name : Upload artifact
51
- uses : actions/upload-pages-artifact@v3
52
- with :
53
- path : docs/.vitepress/dist
54
-
55
- # 部署工作
56
- deploy :
57
- environment :
58
- name : github-pages
59
- url : ${{ steps.deployment.outputs.page_url }}
60
- needs : build
61
- runs-on : ubuntu-latest
62
- name : Deploy
63
- steps :
64
- - name : Deploy to GitHub Pages
65
- id : deployment
1
+ name : Deploy VitePress site to Pages
2
+
3
+ on :
4
+ push :
5
+ branches : [main]
6
+ workflow_dispatch :
7
+
8
+ permissions :
9
+ contents : read
10
+ pages : write
11
+ id-token : write
12
+
13
+ concurrency :
14
+ group : pages
15
+ cancel-in-progress : false
16
+
17
+ jobs :
18
+ build :
19
+ runs-on : ubuntu-latest
20
+ steps :
21
+ - name : Checkout
22
+ uses : actions/checkout@v4
23
+ - name : Setup Node
24
+ uses : actions/setup-node@v4
25
+ with :
26
+ node-version : 20
27
+ cache : npm
28
+ - name : Setup Pages
29
+ uses : actions/configure-pages@v4
30
+ - name : Install dependencies
31
+ run : npm install --legacy-peer-deps
32
+ - name : Build
33
+ run : npm run docs:build
34
+ - name : Upload artifact
35
+ uses : actions/upload-pages-artifact@v3
36
+ with :
37
+ path : docs/.vitepress/dist
38
+
39
+ deploy :
40
+ environment :
41
+ name : github-pages
42
+ url : ${{ steps.deployment.outputs.page_url }}
43
+ needs : build
44
+ runs-on : ubuntu-latest
45
+ name : Deploy
46
+ steps :
47
+ - name : Deploy to GitHub Pages
48
+ id : deployment
66
49
uses : actions/deploy-pages@v4
0 commit comments