File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11name : Deploy VitePress
22
3+ # 推到 main 即自动构建,产物作为一次性 artifact 部署到 GitHub Pages(不提交进任何分支)。
4+ # 首次使用前:仓库 Settings → Pages → Source 必须选「GitHub Actions」(非 Deploy from a branch)。
35on :
46 push :
57 branches :
68 - main
79 workflow_dispatch :
810
911permissions :
10- contents : write
12+ contents : read
13+ pages : write
14+ id-token : write # deploy-pages 经 OIDC 验证部署来源,必需
15+
16+ # 同一时间只跑一个部署,排队中的不取消,保证最新一次一定部署成功
17+ concurrency :
18+ group : pages
19+ cancel-in-progress : false
1120
1221jobs :
13- deploy :
22+ build :
1423 runs-on : ubuntu-latest
15-
1624 steps :
1725 - name : Checkout
1826 uses : actions/checkout@v4
1927 with :
2028 fetch-depth : 0
2129
22- - name : Setup Node.js
23- uses : actions/setup-node@v4
24- with :
25- node-version : ' 22'
26-
2730 - name : Setup pnpm
2831 uses : pnpm/action-setup@v4
2932 with :
3033 version : 10
3134
35+ - name : Setup Node.js
36+ uses : actions/setup-node@v4
37+ with :
38+ node-version : ' 22'
39+ cache : pnpm
40+
3241 - name : Install dependencies
3342 run : pnpm install --frozen-lockfile
3443
44+ - name : Setup Pages
45+ uses : actions/configure-pages@v5
46+
3547 - name : Build
3648 run : pnpm build
3749
38- - name : Deploy to GitHub Pages
39- uses : peaceiris/ actions-gh- pages@v4
50+ - name : Upload artifact
51+ uses : actions/upload- pages-artifact@v3
4052 with :
41- github_token : ${{ secrets.GITHUB_TOKEN }}
42- publish_dir : ./site/.vitepress/dist
53+ path : site/.vitepress/dist
54+
55+ deploy :
56+ needs : build
57+ runs-on : ubuntu-latest
58+ environment :
59+ name : github-pages
60+ url : ${{ steps.deployment.outputs.page_url }}
61+ steps :
62+ - name : Deploy to GitHub Pages
63+ id : deployment
64+ uses : actions/deploy-pages@v4
You can’t perform that action at this time.
0 commit comments