Skip to content

Commit bf90d4f

Browse files
committed
config:deploy yml
1 parent 2be6d81 commit bf90d4f

File tree

1 file changed

+33
-24
lines changed

1 file changed

+33
-24
lines changed

.github/workflows/deploy.yml

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,45 @@
1-
name: Next.js Deploy to GitHub Pages
1+
name: Deploy Next.js site to Pages
22

33
on:
44
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
716

817
jobs:
918
build:
10-
runs-on: ubuntu-latest # 使用最新的 Ubuntu 环境
11-
19+
runs-on: ubuntu-latest
1220
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
2025
with:
21-
node-version: '18' # 设置 Node.js 版本,确保和你的项目兼容
22-
23-
# Step 3: 安装依赖
26+
node-version: "20"
2427
- name: Install dependencies
25-
run: npm install
26-
27-
# Step 4: 构建项目
28-
- name: Build
28+
run: npm ci
29+
- name: Build with Next.js
2930
run: npm run build
31+
- name: Upload artifact
32+
uses: actions/upload-pages-artifact@v3
33+
with:
34+
path: ./out
3035

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:
3243
- 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

0 commit comments

Comments
 (0)