-
Notifications
You must be signed in to change notification settings - Fork 2
228 lines (169 loc) · 6.7 KB
/
deployment.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Deployment CI
on: [ push, pull_request ]
jobs:
# BUILD PROJECT AND DEPENDENCIES
build:
# if: "!contains(github.event.head_commit.message, 'ci skip')"
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 20.12.x ]
steps:
- uses: actions/checkout@v4
- name: Cache project node-modules
uses: actions/cache@v4
with:
path: 'node_modules'
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/package-lock.json') }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Installing NX
run: npm install -g nx@15.9.2
# pipeline actions
- run: npm ci
- name: Build blog Dashboard (prod)
run: npm run build:admin:prod
# run: nx run dashboard:build:production
- name: Build blog Blog (prod)
run: npm run build:ssr
# run: nx run blog:build:production && nx run blog:server:production
# RUN TESTS
test:
needs: [ build ]
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 20.12.x ]
steps:
- uses: actions/checkout@v4
- name: Cache project node-modules
uses: actions/cache@v4
with:
path: 'node_modules'
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/package-lock.json') }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install codecov dependency
run: npm install -g codecov
# pipeline actions
# - run: npm run lint # toDo: until lint is fixed
- run: npm test
- run: codecov
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# DEPLOY DASHBOARD (DEVELOP)
deploy-dashboard-dev:
needs: [ test ]
if: github.ref == 'refs/heads/develop'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Copy project to the hosting
uses: easingthemes/ssh-deploy@main
env:
SSH_PRIVATE_KEY: ${{ secrets.SERVER_SSH_KEY }}
ARGS: "-rltgoDzvO --delete"
SOURCE: ""
REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
REMOTE_USER: ${{ secrets.REMOTE_USER }}
TARGET: ${{ secrets.DEV__REMOTE_TARGET }}
- name: Deploy project with docker in hosting
uses: garygrossgarten/github-action-ssh@release
with:
command: cd ${{ secrets.DEV__REMOTE_TARGET }} && ENVIRONMENT=dev PORT_FRONTEND=${{ secrets.DEV__PORT_FRONTEND_DASHBOARD }} ./docker/deploy.sh blog-admin-dev docker/docker-compose.admin.yml
host: ${{ secrets.REMOTE_HOST }}
username: ${{ secrets.REMOTE_USER }}
privateKey: ${{ secrets.SERVER_SSH_KEY}}
# DEPLOY BLOG (DEVELOP)
deploy-blog-dev:
needs: [ deploy-dashboard-dev ]
if: github.ref == 'refs/heads/develop'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Copy project to the hosting
uses: easingthemes/ssh-deploy@main
env:
SSH_PRIVATE_KEY: ${{ secrets.SERVER_SSH_KEY }}
ARGS: "-rltgoDzvO --delete"
SOURCE: ""
REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
REMOTE_USER: ${{ secrets.REMOTE_USER }}
TARGET: ${{ secrets.DEV__REMOTE_TARGET }}
- name: Deploy project with docker in hosting
uses: garygrossgarten/github-action-ssh@release
with:
command: cd ${{ secrets.DEV__REMOTE_TARGET }} && ENVIRONMENT=dev PORT_FRONTEND=${{ secrets.DEV__PORT_FRONTEND_BLOG }} ./docker/deploy.sh blog-frontend-dev docker/docker-compose.yml
host: ${{ secrets.REMOTE_HOST }}
username: ${{ secrets.REMOTE_USER }}
privateKey: ${{ secrets.SERVER_SSH_KEY}}
# UPDATE APPLICATION VERSION
update-version:
needs: [ test ]
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 20.12.x ]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Update app version in package.json
run: node ./docker/update-version.js
- name: Commit and push changes
run: ./docker/commit-version.sh
# DEPLOY DASHBOARD (PRODUCTION)
deploy-dashboard-prod:
needs: [ update-version ]
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Copy project to the hosting
uses: easingthemes/ssh-deploy@main
env:
SSH_PRIVATE_KEY: ${{ secrets.PROD__SERVER_SSH_KEY }}
ARGS: "-rltgoDzvO --delete"
SOURCE: ""
REMOTE_HOST: ${{ secrets.PROD__REMOTE_HOST }}
REMOTE_USER: ${{ secrets.PROD__REMOTE_USER }}
TARGET: ${{ secrets.PROD__REMOTE_TARGET }}
- name: Deploy project with docker in hosting
uses: garygrossgarten/github-action-ssh@release
with:
command: cd ${{ secrets.PROD__REMOTE_TARGET }} && PORT_FRONTEND=${{ secrets.PROD__PORT_FRONTEND_DASHBOARD }} ./docker/deploy.sh dashboard-prod-v4 docker/docker-compose.admin.yml
host: ${{ secrets.PROD__REMOTE_HOST }}
username: ${{ secrets.PROD__REMOTE_USER }}
privateKey: ${{ secrets.PROD__SERVER_SSH_KEY}}
# DEPLOY BLOG (PRODUCTION)
deploy-blog-prod:
needs: [ deploy-dashboard-prod ]
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Copy project to the hosting
uses: easingthemes/ssh-deploy@main
env:
SSH_PRIVATE_KEY: ${{ secrets.PROD__SERVER_SSH_KEY }}
ARGS: "-rltgoDzvO --delete"
SOURCE: ""
REMOTE_HOST: ${{ secrets.PROD__REMOTE_HOST }}
REMOTE_USER: ${{ secrets.PROD__REMOTE_USER }}
TARGET: ${{ secrets.PROD__REMOTE_TARGET }}
- name: Deploy project with docker in hosting
uses: garygrossgarten/github-action-ssh@release
with:
command: cd ${{ secrets.PROD__REMOTE_TARGET }} && PORT_FRONTEND=${{ secrets.PROD__PORT_FRONTEND_BLOG }} ./docker/deploy.sh frontend-prod-v4 docker/docker-compose.yml
host: ${{ secrets.PROD__REMOTE_HOST }}
username: ${{ secrets.PROD__REMOTE_USER }}
privateKey: ${{ secrets.PROD__SERVER_SSH_KEY}}