File tree Expand file tree Collapse file tree 1 file changed +33
-24
lines changed Expand file tree Collapse file tree 1 file changed +33
-24
lines changed Original file line number Diff line number Diff line change 1
- name : Next.js Deploy to GitHub Pages
1
+ name : Deploy Next.js site to Pages
2
2
3
3
on :
4
4
push :
5
- branches :
6
- - main # 每次推送到 main 分支时触发
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
7
16
8
17
jobs :
9
18
build :
10
- runs-on : ubuntu-latest # 使用最新的 Ubuntu 环境
11
-
19
+ runs-on : ubuntu-latest
12
20
steps :
13
- # Step 1: 检出代码
14
- - name : Checkout code
15
- uses : actions/checkout@v2
16
-
17
- # Step 2: 设置 Node.js 环境
18
- - name : Set up Node.js
19
- uses : actions/setup-node@v2
21
+ - name : Checkout
22
+ uses : actions/checkout@v4
23
+ - name : Setup Node
24
+ uses : actions/setup-node@v4
20
25
with :
21
- node-version : ' 18' # 设置 Node.js 版本,确保和你的项目兼容
22
-
23
- # Step 3: 安装依赖
26
+ node-version : " 20"
24
27
- name : Install dependencies
25
- run : npm install
26
-
27
- # Step 4: 构建项目
28
- - name : Build
28
+ run : npm ci
29
+ - name : Build with Next.js
29
30
run : npm run build
31
+ - name : Upload artifact
32
+ uses : actions/upload-pages-artifact@v3
33
+ with :
34
+ path : ./out
30
35
31
- # Step 6: 部署到 GitHub Pages
36
+ deploy :
37
+ environment :
38
+ name : github-pages
39
+ url : ${{ steps.deployment.outputs.page_url }}
40
+ runs-on : ubuntu-latest
41
+ needs : build
42
+ steps :
32
43
- name : Deploy to GitHub Pages
33
- uses : JamesIves/github-pages-deploy-action@v4
34
- with :
35
- branch : build
36
- folder : out
44
+ id : deployment
45
+ uses : actions/deploy-pages@v4
You can’t perform that action at this time.
0 commit comments