File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Build and Deploy to GitHub Pages
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+ workflow_dispatch : # 允许手动触发
8+
9+ jobs :
10+ build :
11+ runs-on : ubuntu-latest
12+ permissions :
13+ contents : write # 明确声明需要的权限
14+ pages : write
15+ id-token : write
16+
17+ steps :
18+ - name : Checkout Source
19+ uses : actions/checkout@v4 # 升级到最新版本
20+
21+ - name : Setup Node.js
22+ uses : actions/setup-node@v4
23+ with :
24+ node-version : ' 20' # 使用最新的LTS版本
25+ cache : ' npm' # 自动缓存npm依赖
26+
27+ - name : Install Dependencies
28+ run : npm ci # 使用ci而不是install以获得更可靠的构建
29+
30+ - name : Build
31+ run : npm run build
32+
33+ - name : Setup Pages
34+ uses : actions/configure-pages@v4
35+
36+ - name : Upload artifact
37+ uses : actions/upload-pages-artifact@v2
38+ with :
39+ path : ' ./dist' # 上传构建产物
40+
41+ - name : Deploy to GitHub Pages
42+ uses : actions/deploy-pages@v2 # 使用官方部署action
You can’t perform that action at this time.
0 commit comments