-
Notifications
You must be signed in to change notification settings - Fork 7
96 lines (85 loc) Β· 2.88 KB
/
deploy-dev.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
name: Node.js CD
on:
push:
branches:
- dev
jobs:
deploy:
name: Build and Deploy to nCloud
runs-on: ubuntu-latest
env:
client-directory: ./client
server-directory: ./server
CI: false
steps:
- uses: actions/checkout@v2
- name: Set Node.js 16.x
uses: actions/[email protected]
with:
node-version: 16.x
- name: Client npm install
run: npm install
working-directory: ${{env.client-directory}}
- name: Client Build
run: npm run build
working-directory: ${{env.client-directory}}
- name: Server npm install
working-directory: ${{env.server-directory}}
run: npm install
- name: Create server .env file
working-directory: ${{env.server-directory}}
run: |
touch .env
echo DB_USER=${{ secrets.DB_USER }}\ >> .env
echo DB_PASSWORD=${{ secrets.DB_PASSWORD }}\ >> .env
echo SESSION_COOKIE_SECRET=${{ secrets.SESSION_COOKIE_SECRET }}\ >> .env
echo S3_ACCESS_KEY=${{ secrets.S3_ACCESS_KEY }}\ >> .env
echo S3_SECRET_KEY=${{ secrets.S3_SECRET_KEY }}\ >> .env
echo S3_ENDPOINT=${{ secrets.S3_ENDPOINT }}\ >> .env
echo S3_REGION=${{ secrets.S3_REGION }}\ >> .env
echo S3_BUCKET_NAME=${{ secrets.S3_BUCKET_NAME }}\ >> .env
cat .env
- name: Server Build
run: npm run build
working-directory: ${{env.server-directory}}
- name: clean-up deploy server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
port: ${{ secrets.PORT_DEV }}
script: |
rm -rf /usr/share/nginx/html/*
cd duxcord
rm -rf *
- name: copy client file to deploy server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
port: ${{ secrets.PORT_DEV }}
source: './client/build'
target: '/usr/share/nginx/html'
- name: copy server file to deploy server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
port: ${{ secrets.PORT_DEV }}
source: './server/dist'
target: 'duxcord'
- name: start app server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
port: ${{ secrets.PORT_DEV }}
script: |
chown root duxcord/server
cd duxcord/server/dist
pm2 start main.js
pm2 reload main.js