@@ -3,8 +3,10 @@ name: ocelot.social publish CI
3
3
on :
4
4
push :
5
5
branches :
6
- # - master
7
- - 5059-epic-groups # for testing while developing
6
+ - master
7
+ # - 5059-epic-groups # for testing while developing
8
+ # template branches in repo
9
+ # - template--separate-branch-auto-deployment--5059-epic-groups
8
10
9
11
jobs :
10
12
# #############################################################################
@@ -94,16 +96,16 @@ jobs:
94
96
# #########################################################################
95
97
- name : Backend | Build `production` image
96
98
run : |
97
- docker build --target base -t "ocelotsocialnetwork/backend-groups :latest-base" -t "ocelotsocialnetwork/backend-groups :${VERSION}-base" -t "ocelotsocialnetwork/backend-groups :${BUILD_VERSION}-base" --build-arg BBUILD_DATE=$BUILD_DATE --build-arg BBUILD_VERSION=$BUILD_VERSION --build-arg BBUILD_COMMIT=$BUILD_COMMIT backend/
98
- docker build --target code -t "ocelotsocialnetwork/backend-groups :latest-code" -t "ocelotsocialnetwork/backend-groups :${VERSION}-code" -t "ocelotsocialnetwork/backend-groups :${BUILD_VERSION}-code" --build-arg BBUILD_DATE=$BUILD_DATE --build-arg BBUILD_VERSION=$BUILD_VERSION --build-arg BBUILD_COMMIT=$BUILD_COMMIT backend/
99
- docker build --target production -t "ocelotsocialnetwork/backend-groups :latest" -t "ocelotsocialnetwork/backend-groups :${VERSION}" -t "ocelotsocialnetwork/backend-groups :${BUILD_VERSION}" --build-arg BBUILD_DATE=$BUILD_DATE --build-arg BBUILD_VERSION=$BUILD_VERSION --build-arg BBUILD_COMMIT=$BUILD_COMMIT backend/
99
+ docker build --target base -t "ocelotsocialnetwork/backend:latest-base" -t "ocelotsocialnetwork/backend:${VERSION}-base" -t "ocelotsocialnetwork/backend:${BUILD_VERSION}-base" --build-arg BBUILD_DATE=$BUILD_DATE --build-arg BBUILD_VERSION=$BUILD_VERSION --build-arg BBUILD_COMMIT=$BUILD_COMMIT backend/
100
+ docker build --target code -t "ocelotsocialnetwork/backend:latest-code" -t "ocelotsocialnetwork/backend:${VERSION}-code" -t "ocelotsocialnetwork/backend:${BUILD_VERSION}-code" --build-arg BBUILD_DATE=$BUILD_DATE --build-arg BBUILD_VERSION=$BUILD_VERSION --build-arg BBUILD_COMMIT=$BUILD_COMMIT backend/
101
+ docker build --target production -t "ocelotsocialnetwork/backend:latest" -t "ocelotsocialnetwork/backend:${VERSION}" -t "ocelotsocialnetwork/backend:${BUILD_VERSION}" --build-arg BBUILD_DATE=$BUILD_DATE --build-arg BBUILD_VERSION=$BUILD_VERSION --build-arg BBUILD_COMMIT=$BUILD_COMMIT backend/
100
102
- name : Backend | Save docker image
101
- run : docker save "ocelotsocialnetwork/backend-groups " > /tmp/backend-groups .tar
103
+ run : docker save "ocelotsocialnetwork/backend" > /tmp/backend.tar
102
104
- name : Upload Artifact
103
105
uses : actions/upload-artifact@v2
104
106
with :
105
107
name : docker-backend-production
106
- path : /tmp/backend-groups .tar
108
+ path : /tmp/backend.tar
107
109
108
110
# #############################################################################
109
111
# JOB: DOCKER BUILD PRODUCTION WEBAPP ########################################
@@ -134,16 +136,16 @@ jobs:
134
136
# #########################################################################
135
137
- name : Webapp | Build `production` image
136
138
run : |
137
- docker build --target base -t "ocelotsocialnetwork/webapp-groups :latest-base" -t "ocelotsocialnetwork/webapp-groups :${VERSION}-base" -t "ocelotsocialnetwork/webapp-groups :${BUILD_VERSION}-base" --build-arg BBUILD_DATE=$BUILD_DATE --build-arg BBUILD_VERSION=$BUILD_VERSION --build-arg BBUILD_COMMIT=$BUILD_COMMIT webapp/
138
- docker build --target code -t "ocelotsocialnetwork/webapp-groups :latest-code" -t "ocelotsocialnetwork/webapp-groups :${VERSION}-code" -t "ocelotsocialnetwork/webapp-groups :${BUILD_VERSION}-code" --build-arg BBUILD_DATE=$BUILD_DATE --build-arg BBUILD_VERSION=$BUILD_VERSION --build-arg BBUILD_COMMIT=$BUILD_COMMIT webapp/
139
- docker build --target production -t "ocelotsocialnetwork/webapp-groups :latest" -t "ocelotsocialnetwork/webapp-groups :${VERSION}" -t "ocelotsocialnetwork/webapp-groups :${BUILD_VERSION}" --build-arg BBUILD_DATE=$BUILD_DATE --build-arg BBUILD_VERSION=$BUILD_VERSION --build-arg BBUILD_COMMIT=$BUILD_COMMIT webapp/
139
+ docker build --target base -t "ocelotsocialnetwork/webapp:latest-base" -t "ocelotsocialnetwork/webapp:${VERSION}-base" -t "ocelotsocialnetwork/webapp:${BUILD_VERSION}-base" --build-arg BBUILD_DATE=$BUILD_DATE --build-arg BBUILD_VERSION=$BUILD_VERSION --build-arg BBUILD_COMMIT=$BUILD_COMMIT webapp/
140
+ docker build --target code -t "ocelotsocialnetwork/webapp:latest-code" -t "ocelotsocialnetwork/webapp:${VERSION}-code" -t "ocelotsocialnetwork/webapp:${BUILD_VERSION}-code" --build-arg BBUILD_DATE=$BUILD_DATE --build-arg BBUILD_VERSION=$BUILD_VERSION --build-arg BBUILD_COMMIT=$BUILD_COMMIT webapp/
141
+ docker build --target production -t "ocelotsocialnetwork/webapp:latest" -t "ocelotsocialnetwork/webapp:${VERSION}" -t "ocelotsocialnetwork/webapp:${BUILD_VERSION}" --build-arg BBUILD_DATE=$BUILD_DATE --build-arg BBUILD_VERSION=$BUILD_VERSION --build-arg BBUILD_COMMIT=$BUILD_COMMIT webapp/
140
142
- name : Webapp | Save docker image
141
- run : docker save "ocelotsocialnetwork/webapp-groups " > /tmp/webapp-groups .tar
143
+ run : docker save "ocelotsocialnetwork/webapp" > /tmp/webapp.tar
142
144
- name : Upload Artifact
143
145
uses : actions/upload-artifact@v2
144
146
with :
145
147
name : docker-webapp-production
146
- path : /tmp/webapp-groups .tar
148
+ path : /tmp/webapp.tar
147
149
148
150
# #############################################################################
149
151
# JOB: DOCKER BUILD PRODUCTION MAINTENANCE ###################################
@@ -174,16 +176,16 @@ jobs:
174
176
# #########################################################################
175
177
- name : Maintenance | Build `production` image
176
178
run : |
177
- docker build --target base -t "ocelotsocialnetwork/maintenance-groups :latest-base" -t "ocelotsocialnetwork/maintenance-groups :${VERSION}-base" -t "ocelotsocialnetwork/maintenance-groups :${BUILD_VERSION}-base" --build-arg BBUILD_DATE=$BUILD_DATE --build-arg BBUILD_VERSION=$BUILD_VERSION --build-arg BBUILD_COMMIT=$BUILD_COMMIT webapp/ -f webapp/Dockerfile.maintenance
178
- docker build --target code -t "ocelotsocialnetwork/maintenance-groups :latest-code" -t "ocelotsocialnetwork/maintenance-groups :${VERSION}-code" -t "ocelotsocialnetwork/maintenance-groups :${BUILD_VERSION}-code" --build-arg BBUILD_DATE=$BUILD_DATE --build-arg BBUILD_VERSION=$BUILD_VERSION --build-arg BBUILD_COMMIT=$BUILD_COMMIT webapp/ -f webapp/Dockerfile.maintenance
179
- docker build --target production -t "ocelotsocialnetwork/maintenance-groups :latest" -t "ocelotsocialnetwork/maintenance-groups :${VERSION}" -t "ocelotsocialnetwork/maintenance-groups :${BUILD_VERSION}" --build-arg BBUILD_DATE=$BUILD_DATE --build-arg BBUILD_VERSION=$BUILD_VERSION --build-arg BBUILD_COMMIT=$BUILD_COMMIT webapp/ -f webapp/Dockerfile.maintenance
179
+ docker build --target base -t "ocelotsocialnetwork/maintenance:latest-base" -t "ocelotsocialnetwork/maintenance:${VERSION}-base" -t "ocelotsocialnetwork/maintenance:${BUILD_VERSION}-base" --build-arg BBUILD_DATE=$BUILD_DATE --build-arg BBUILD_VERSION=$BUILD_VERSION --build-arg BBUILD_COMMIT=$BUILD_COMMIT webapp/ -f webapp/Dockerfile.maintenance
180
+ docker build --target code -t "ocelotsocialnetwork/maintenance:latest-code" -t "ocelotsocialnetwork/maintenance:${VERSION}-code" -t "ocelotsocialnetwork/maintenance:${BUILD_VERSION}-code" --build-arg BBUILD_DATE=$BUILD_DATE --build-arg BBUILD_VERSION=$BUILD_VERSION --build-arg BBUILD_COMMIT=$BUILD_COMMIT webapp/ -f webapp/Dockerfile.maintenance
181
+ docker build --target production -t "ocelotsocialnetwork/maintenance:latest" -t "ocelotsocialnetwork/maintenance:${VERSION}" -t "ocelotsocialnetwork/maintenance:${BUILD_VERSION}" --build-arg BBUILD_DATE=$BUILD_DATE --build-arg BBUILD_VERSION=$BUILD_VERSION --build-arg BBUILD_COMMIT=$BUILD_COMMIT webapp/ -f webapp/Dockerfile.maintenance
180
182
- name : Maintenance | Save docker image
181
- run : docker save "ocelotsocialnetwork/maintenance-groups " > /tmp/maintenance-groups .tar
183
+ run : docker save "ocelotsocialnetwork/maintenance" > /tmp/maintenance.tar
182
184
- name : Upload Artifact
183
185
uses : actions/upload-artifact@v2
184
186
with :
185
187
name : docker-maintenance-production
186
- path : /tmp/maintenance-groups .tar
188
+ path : /tmp/maintenance.tar
187
189
188
190
# #############################################################################
189
191
# JOB: UPLOAD TO DOCKERHUB ###################################################
@@ -217,21 +219,21 @@ jobs:
217
219
name : docker-backend-production
218
220
path : /tmp
219
221
- name : Load Docker Image
220
- run : docker load < /tmp/backend-groups .tar
222
+ run : docker load < /tmp/backend.tar
221
223
- name : Download Docker Image (WebApp)
222
224
uses : actions/download-artifact@v2
223
225
with :
224
226
name : docker-webapp-production
225
227
path : /tmp
226
228
- name : Load Docker Image
227
- run : docker load < /tmp/webapp-groups .tar
229
+ run : docker load < /tmp/webapp.tar
228
230
- name : Download Docker Image (Maintenance)
229
231
uses : actions/download-artifact@v2
230
232
with :
231
233
name : docker-maintenance-production
232
234
path : /tmp
233
235
- name : Load Docker Image
234
- run : docker load < /tmp/maintenance-groups .tar
236
+ run : docker load < /tmp/maintenance.tar
235
237
# #########################################################################
236
238
# Upload #################################################################
237
239
# #########################################################################
@@ -240,11 +242,11 @@ jobs:
240
242
- name : Push neo4j
241
243
run : docker push --all-tags ocelotsocialnetwork/neo4j-community
242
244
- name : Push backend
243
- run : docker push --all-tags ocelotsocialnetwork/backend-groups
245
+ run : docker push --all-tags ocelotsocialnetwork/backend
244
246
- name : Push webapp
245
- run : docker push --all-tags ocelotsocialnetwork/webapp-groups
247
+ run : docker push --all-tags ocelotsocialnetwork/webapp
246
248
- name : Push maintenance
247
- run : docker push --all-tags ocelotsocialnetwork/maintenance-groups
249
+ run : docker push --all-tags ocelotsocialnetwork/maintenance
248
250
249
251
# #############################################################################
250
252
# JOB: KUBERNETES DEPLOY ACTUAL/LATEST VERSION ######################################
@@ -292,27 +294,30 @@ jobs:
292
294
# kubectl -n default rollout restart deployment/ocelot-neo4j
293
295
- name : Deploy actual version '$BUILD_VERSION' to DigitalOcean Kubernetes
294
296
run : |
295
- kubectl -n default set image deployment/ocelot-webapp container-ocelot-webapp=ocelotsocialnetwork/webapp-groups :$BUILD_VERSION
297
+ kubectl -n default set image deployment/ocelot-webapp container-ocelot-webapp=ocelotsocialnetwork/webapp:$BUILD_VERSION
296
298
kubectl -n default rollout restart deployment/ocelot-webapp
297
- kubectl -n default set image deployment/ocelot-backend container-ocelot-backend=ocelotsocialnetwork/backend-groups :$BUILD_VERSION
299
+ kubectl -n default set image deployment/ocelot-backend container-ocelot-backend=ocelotsocialnetwork/backend:$BUILD_VERSION
298
300
kubectl -n default rollout restart deployment/ocelot-backend
299
- kubectl -n default set image deployment/ocelot-maintenance container-ocelot-maintenance=ocelotsocialnetwork/maintenance-groups :$BUILD_VERSION
301
+ kubectl -n default set image deployment/ocelot-maintenance container-ocelot-maintenance=ocelotsocialnetwork/maintenance:$BUILD_VERSION
300
302
kubectl -n default rollout restart deployment/ocelot-maintenance
301
303
kubectl -n default set image deployment/ocelot-neo4j container-ocelot-neo4j=ocelotsocialnetwork/neo4j-community:$BUILD_VERSION
302
304
kubectl -n default rollout restart deployment/ocelot-neo4j
303
305
# because this step 'kubectl -n default rollout status deployment/* --timeout=600s' does not work as expected
304
306
# and we need the pods to be up again for cleaning and seeding the Neo4j database and the backend.
305
307
# !!! this is not a perfect solution !!!
306
- # deployments are regularely up again after 3 minutes and 10 seconds
308
+ # deployments are regularly up again after 3 minutes and 10 seconds
307
309
- name : Sleep for 4 minutes, means 240 seconds
308
310
run : sleep 240s
309
311
shell : bash
310
- - name : Verify deployment and wait for the pods of each deplyment to get ready for cleaning and seeding of the database
312
+ - name : Verify deployment and wait for the pods of each deployment to get ready for cleaning and seeding of the database
311
313
run : |
312
314
kubectl -n default rollout status deployment/ocelot-backend --timeout=600s
313
315
kubectl -n default rollout status deployment/ocelot-neo4j --timeout=600s
314
316
kubectl -n default rollout status deployment/ocelot-maintenance --timeout=600s
315
317
kubectl -n default rollout status deployment/ocelot-webapp --timeout=600s
318
+ - name : Run migrations for Neo4j database via backend for staging
319
+ run : |
320
+ kubectl -n default exec -it $(kubectl -n default get pods | grep ocelot-backend | awk '{ print $1 }') -- /bin/sh -c "yarn prod:migrate up"
316
321
- name : Reset and seed Neo4j database via backend for staging
317
322
# db cleaning and seeding is only possible in production if env 'PRODUCTION_DB_CLEAN_ALLOW=true' is set in deployment
318
323
run : |
0 commit comments