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
30+ - name : Setup pnpm
31+ uses : pnpm/action-setup@v4
32+ with :
33+ version : 10
34+
2235 - name : Setup Node.js
2336 uses : actions/setup-node@v4
2437 with :
2538 node-version : ' 22'
26-
27- - name : Setup pnpm
28- uses : pnpm/action-setup@v4
39+ cache : pnpm
2940
3041 - name : Install dependencies
3142 run : pnpm install --frozen-lockfile
3243
44+ - name : Setup Pages
45+ uses : actions/configure-pages@v5
46+
3347 - name : Build
3448 run : pnpm build
3549
36- - name : Deploy to GitHub Pages
37- uses : peaceiris/ actions-gh- pages@v4
50+ - name : Upload artifact
51+ uses : actions/upload- pages-artifact@v3
3852 with :
39- github_token : ${{ secrets.GITHUB_TOKEN }}
40- 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