1- name : Deploy VitePress site to GitHub Pages
1+ # 构建 VitePress 站点并将其部署到 GitHub Pages 的示例工作流程
2+ #
3+ name : Deploy VitePress site to Pages
24
35on :
6+ # 在针对 `main` 分支的推送上运行
47 push :
5- branches :
6- - main
8+ branches : [main]
9+
10+ # 允许你从 Actions 选项卡手动运行此工作流程
11+ workflow_dispatch :
12+
13+ # 设置 GITHUB_TOKEN 的权限,以允许部署到 GitHub Pages
14+ permissions :
15+ contents : read
16+ pages : write
17+ id-token : write
18+
19+ # 只允许同时进行一次部署,跳过正在运行和最新队列之间的运行队列
20+ concurrency :
21+ group : pages
22+ cancel-in-progress : true
723
824jobs :
9- deploy :
25+ # 构建工作
26+ build :
1027 runs-on : ubuntu-latest
11- concurrency :
12- group : deploy-pages
13- cancel-in-progress : true
1428 steps :
15- - name : Checkout source
16- uses : actions/checkout@v3
17-
18- - name : Setup Node.js
19- uses : actions/setup-node@v3
29+ - name : Checkout
30+ uses : actions/checkout@v4
2031 with :
21- node-version : 18
22-
23- - name : Setup pnpm
24- uses : pnpm/action-setup@v2
32+ fetch-depth : 0 # 如果未启用 lastUpdated,则不需要
33+ - uses : pnpm/action-setup@v3 # 如果使用 pnpm,请取消此区域注释
2534 with :
2635 version : 9
27-
36+ - name : Setup Node
37+ uses : actions/setup-node@v4
38+ with :
39+ node-version : 18
40+ cache : pnpm
41+ - name : Setup Pages
42+ uses : actions/configure-pages@v4
2843 - name : Install dependencies
2944 run : pnpm install
30-
31- - name : Build site
45+ - name : Build with VitePress
3246 run : pnpm run build
47+ - name : Upload artifact
48+ uses : actions/upload-pages-artifact@v3
49+ with :
50+ path : docs/.vitepress/dist
3351
52+ # 部署工作
53+ deploy :
54+ environment :
55+ name : github-pages
56+ url : ${{ steps.deployment.outputs.page_url }}
57+ needs : build
58+ runs-on : ubuntu-latest
59+ name : Deploy
60+ steps :
3461 - name : Deploy to GitHub Pages
35- uses : peaceiris/actions-gh-pages@v4
36- with :
37- github_token : ${{ secrets.GITHUB_TOKEN }}
38- publish_dir : ./docs/.vitepress/dist
62+ id : deployment
63+ uses : actions/deploy-pages@v4
0 commit comments