-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (54 loc) · 1.49 KB
/
main.yml
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
name: Full Stack Deployment
on:
push:
branches:
- main
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
# 安装 Node.js 和 npm
- name: Install Node.js and npm
uses: actions/setup-node@v2.1.5
with:
node-version: '14'
# 安装 vte 和其他前端依赖
- name: Install frontend dependencies
working-directory: ./client
run: |
npm install vite -g
npm install
env:
NODE_ENV: production
# 前端构建步骤
- name: Build Vue App
working-directory: ./client
run: |
npm run build
env:
NODE_ENV: production
# 缓存前端构建依赖
- name: Cache frontend dependencies
uses: actions/cache@v2
with:
path: client/node_modules
key: ${{ runner.os }}-frontend-${{ hashFiles('client/package-lock.json') }}
# 复制前端构建结果到后端的public目录
- name: Copy frontend build output to server
run: cp -r ./client/dist ./server/public
# 后端构建步骤
- name: Build and start Node.js server
working-directory: ./server
run: |
npm install
npm run start &
env:
NODE_ENV: production
# 缓存后端构建依赖
- name: Cache backend dependencies
uses: actions/cache@v2
with:
path: server/node_modules
key: ${{ runner.os }}-backend-${{ hashFiles('server/package-lock.json') }}