-
Notifications
You must be signed in to change notification settings - Fork 1
41 lines (34 loc) · 1.01 KB
/
build.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
name: Auto Build and Deploy to Build Branch
on:
push:
branches:
- 'main' # 只监听 main 分支的提交
jobs:
build:
runs-on: ubuntu-latest
steps:
# 检出代码
- name: Checkout code
uses: actions/checkout@v3
# 设置 Node.js 环境
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '16' # 设置 Node.js 版本
# 安装依赖
- name: Install dependencies
run: |
npm install
# 运行构建
- name: Run build
run: |
npm run build
# 发布构建产物到 build 分支
- name: Push build to build branch
run: |
git config --global user.name "github-actions"
git config --global user.email "[email protected]"
git checkout -b build || git checkout build # 如果 build 分支不存在则创建
git add .
git commit -m "Deploy build to build branch"
git push --force origin build