-
Notifications
You must be signed in to change notification settings - Fork 54
138 lines (128 loc) · 4.37 KB
/
build-deploy.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
name: build-deploy
on:
push:
branches: [master]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: master
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: '18.x'
- name: test ssh
uses: appleboy/[email protected]
with:
host: ${{ secrets.REMOTE_HOST }}
username: ${{ secrets.REMOTE_USER }}
key: ${{ secrets.ACCESS_TOKEN }}
port: 22
script: |
whoami
echo "ssh正常连接"
- name: Install server dependencies
run: |
cd server
npm ci
- name: Install web dependencies
run: |
cd web
npm ci
- name: Install web-base dependencies
run: |
cd web-base
npm ci
- name: Install web-base-ant dependencies
run: |
cd web-base-ant
npm ci
- name: Install web-base-naive-ui dependencies
run: |
cd web-base-naive-ui
npm ci
- name: Run build server task
run: |
cd server
npm run build --if-present
- name: Run build web task
run: |
cd web
npm run build --if-present
- name: Run build web-base task
run: |
cd web-base
npm run build --if-present
- name: Run build web-base-ant task
run: |
cd web-base-ant
npm run build --if-present
- name: Run build web-base-naive-ui task
run: |
cd web-base-naive-ui
npm run build --if-present
- name: Deploy server to Server
uses: easingthemes/ssh-deploy@main
with:
SSH_PRIVATE_KEY: ${{ secrets.ACCESS_TOKEN }}
ARGS: '-rlgoDzvc -i'
SOURCE: 'server/'
REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
REMOTE_USER: ${{ secrets.REMOTE_USER }}
TARGET: ${{ vars.REMOTE_DIR }}/server/
EXCLUDE: '/build/, /node_modules/, /src/'
- name: Deploy web to Server
uses: easingthemes/ssh-deploy@main
with:
SSH_PRIVATE_KEY: ${{ secrets.ACCESS_TOKEN }}
ARGS: '-rlgoDzvc -i --delete'
SOURCE: 'web/dist/'
REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
REMOTE_USER: ${{ secrets.REMOTE_USER }}
TARGET: ${{ vars.REMOTE_DIR }}/web/dist/
EXCLUDE: ''
- name: Deploy web-base to Server
uses: easingthemes/ssh-deploy@main
with:
SSH_PRIVATE_KEY: ${{ secrets.ACCESS_TOKEN }}
ARGS: '-rlgoDzvc -i --delete'
SOURCE: 'web-base/dist/'
REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
REMOTE_USER: ${{ secrets.REMOTE_USER }}
TARGET: ${{ vars.REMOTE_DIR }}/web-base/dist/
EXCLUDE: ''
- name: Deploy web-base-ant to Server
uses: easingthemes/ssh-deploy@main
with:
SSH_PRIVATE_KEY: ${{ secrets.ACCESS_TOKEN }}
ARGS: '-rlgoDzvc -i --delete'
SOURCE: 'web-base-ant/dist/'
REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
REMOTE_USER: ${{ secrets.REMOTE_USER }}
TARGET: ${{ vars.REMOTE_DIR }}/web-base-ant/dist/
EXCLUDE: ''
- name: Deploy web-base-naive-ui to Server
uses: easingthemes/ssh-deploy@main
with:
SSH_PRIVATE_KEY: ${{ secrets.ACCESS_TOKEN }}
ARGS: '-rlgoDzvc -i --delete'
SOURCE: 'web-base-naive-ui/dist/'
REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
REMOTE_USER: ${{ secrets.REMOTE_USER }}
TARGET: ${{ vars.REMOTE_DIR }}/web-base-naive-ui/dist/
EXCLUDE: ''
- name: install server dependencies
uses: appleboy/[email protected]
with:
host: ${{ secrets.REMOTE_HOST }}
username: ${{ secrets.REMOTE_USER }}
key: ${{ secrets.ACCESS_TOKEN }}
port: 22
script: |
cd ${{ vars.REMOTE_DIR }}/server/
npm i --production --registry=https://registry.npmmirror.com
pm2 start ${{ vars.REMOTE_DIR }}/server/ecosystem.config.js