-
Notifications
You must be signed in to change notification settings - Fork 2
113 lines (113 loc) · 3.37 KB
/
deploy.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
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
name: Production-Deployment
on:
pull_request:
types:
- closed
branches:
- prod
jobs:
if_merged:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- run: |
echo The PR was merged
run_build:
name: client-server build
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases
steps:
- uses: actions/checkout@v4
with:
ref: prod
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
- run: cd client
- run: npm i --legacy-peer-deps
- run: npm run build --if-present
- run: cd ../
- run: cd server
- run: npm i
- run: npm run build --if-present
run_server_deploy:
runs-on: ubuntu-latest
steps:
- name: runs deploy script
uses: appleboy/ssh-action@v1.0.0
with:
host: ${{ secrets.SSH_HOST_NAME }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_SECRET }}
port: ${{ secrets.PORT }}
script: |
git pull prod
cd ${{ secrets.CD_SERVER }}
chmod +x server_deploy.sh
./server_deploy.sh
run_client_deploy:
needs: run_server_deploy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: clone repository to deploy action
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
- run: |
cd client
export ${{ secrets.ENV_URL }}
export ${{ secrets.GA_TRACKING }}
export ${{ secrets.LINT_DISABLE }}
npm i --legacy-peer-deps
npm run build --verbose
- name: delete build and create new
uses: appleboy/ssh-action@v1.0.0
with:
host: ${{ secrets.SSH_HOST_NAME }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_SECRET }}
port: ${{ secrets.PORT }}
script: |
cd research/client
rm -rf build
mkdir build
- name: tar build to
run: |
cp -TR client/build ../build
tar -cvzf deploy.tar.gz ../build/
- name: scp build directory
uses: appleboy/scp-action@v0.1.4
with:
host: ${{ secrets.SSH_HOST_NAME }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_SECRET }}
port: ${{ secrets.PORT }}
source: "deploy.tar.gz"
target: ${{ secrets.CD_CLIENT }}
- name: Unzip build directory
uses: appleboy/ssh-action@v1.0.0
with:
host: ${{ secrets.SSH_HOST_NAME }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_SECRET }}
port: ${{ secrets.PORT }}
script: |
cd ${{ secrets.CD_CLIENT }}
tar -xvzf deploy.tar.gz
- name: delete zipDeploy directory
uses: appleboy/ssh-action@v1.0.0
with:
host: ${{ secrets.SSH_HOST_NAME }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_SECRET }}
port: ${{ secrets.PORT }}
script: |
cd ${{ secrets.CD_CLIENT }}
rm deploy.tar.gz