-
Notifications
You must be signed in to change notification settings - Fork 4
59 lines (55 loc) · 2.36 KB
/
rebuildServers.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
name: Re-build and re-deploy on test & production servers && trigger CCDH model refresh
on:
workflow_dispatch:
jobs:
rebuild_redeploy:
runs-on: ubuntu-latest
steps:
- name: Run script on server
# shell: bash # Usage: this ensures that env variable usage syntax is correct; Disabled because: causes yaml file syntax error
uses: appleboy/ssh-action@master # https://github.com/appleboy/ssh-action
with:
host: terminology.ccdh.io
username: docker
password: ${{ secrets.DOCKER_USER_PASSWORD }}
# key: ${{ secrets.KEY }} # not needed
# port: ${{ secrets.PORT }} # default: 22
# TODO: Is 'exit' necessary? I'm not 100% sure, but the last time I ran
# the action, it seemed to stay running indefinitely. - jef 2021/07/15
# timeout: 30s # timeout - timeout for ssh to remote host, default is 30s
command_timeout: 60m # command_timeout - timeout for ssh command, default is 10m
# TODO: Since we run this in test and production, should we create a
# .sh script for this and re-use the code instead of have it copied
# 2x here? - jef 2021/07/26
script: |
# 1. Test env
cd /opt/Projects/ccdh-terminology-service
## - Update codebase
# git checkout master
# git pull
# - Deploy
echo Rebuilding test environment.
docker stop ccdh-neo4j-test ccdh-redis-test ccdh-api-test; \
docker rm ccdh-api-test; \
make deploy-local-test; \
echo Running importer in test environment. ; \
docker exec ccdh-api-test python -m ccdh.importers.importer; \
RESULT=$?; \
if [ $RESULT -eq 0 ]; then
# 2. Production env
## - Update codebase
# git checkout master
# git pull
# - Deploy
echo Rebuilding production environment.
docker-compose down
make deploy-local-prod
echo Running importer in production environment.
docker exec ccdh-api python -m ccdh.importers.importer
echo Running CCDH Model integration script in production environment.
docker exec ccdh-api python -m ccdh.integrations.crdc_h
# 3. Exit
exit 0
else
exit 1
fi