Skip to content

Commit 341431d

Browse files
committed
添加GitHub Actions自动部署工作流并修正package.json
1 parent 5f28c60 commit 341431d

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- main # 每次推送到main分支时触发
7+
8+
jobs:
9+
build-and-deploy:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v3
15+
16+
- name: Setup Node.js
17+
uses: actions/setup-node@v3
18+
with:
19+
node-version: '16'
20+
cache: 'npm'
21+
22+
- name: Install dependencies
23+
run: npm ci
24+
25+
- name: Build project
26+
run: npm run build
27+
env:
28+
CI: false # 避免将警告视为错误
29+
30+
- name: Deploy to GitHub Pages
31+
uses: JamesIves/github-pages-deploy-action@v4
32+
with:
33+
folder: build # 构建输出的文件夹
34+
branch: gh-pages # 部署的目标分支
35+
clean: true # 清理旧文件

0 commit comments

Comments
 (0)