-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
138 lines (133 loc) · 4.04 KB
/
.gitlab-ci.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
stages:
- build:backend
- build:frontend
- deploy
build:backend:
stage: build:backend
image: python:3.8
tags:
- deploy
- python3
script:
- python setup.py sdist --format gztar
artifacts:
paths:
- dist/exphewas-*.tar.gz
expire_in: 1 day
dependencies: []
only:
- staging
- deploy
build:staging:frontend:ukbiobank:
stage: build:frontend
image: node:14
tags:
- deploy
before_script:
- cd frontend
- npm install
- export EXPHEWAS_URL_ROOT=/exphewas/ukbiobank
- export WEBPACK_OUTPUT_PATH=dist/ukbiobank
script:
- npm run build
after_script:
- cd frontend/dist/ukbiobank
- tar -zcvf ../frontend_ukbiobank.tar.gz *
artifacts:
paths:
- frontend/dist/frontend_ukbiobank.tar.gz
expire_in: 1 day
dependencies:
- build:backend
needs:
- build:backend
only:
- staging
build:production:frontend:
stage: build:frontend
image: node:14
tags:
- deploy
before_script:
- export EXPHEWAS_MAJOR_VERSION=v$(ls dist/exphewas-*.tar.gz | sort -V | tail -n1 | grep -o -E "[0-9]+\.[0-9]+\.[0-9]+" | cut -d. -f1)
- echo Building for $EXPHEWAS_MAJOR_VERSION
- cd frontend
- npm install
- export EXPHEWAS_URL_ROOT=/$EXPHEWAS_MAJOR_VERSION
script:
- npm run build
after_script:
- cd frontend
- tar -zcvf ./frontend_dist.tar.gz dist
artifacts:
paths:
- frontend/frontend_dist.tar.gz
expire_in: 1 day
dependencies:
- build:backend
needs:
- build:backend
only:
- deploy
deploy:staging:ukbiobank:
stage: deploy
image: fedora:latest
tags:
- deploy
before_script:
- yum install -y openssh-clients
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
- chmod 600 ~/.ssh/known_hosts
script:
- ssh [email protected] "rm -rf /var/www/exphewas/ukbiobank/files/*"
- scp dist/exphewas-*.tar.gz frontend/dist/frontend_ukbiobank.tar.gz [email protected]:/var/www/exphewas/ukbiobank/files
- ssh [email protected] "sudo /usr/bin/systemctl stop exphewas_ukbiobank.service"
- ssh [email protected] "rm -fr /var/www/exphewas/ukbiobank/frontend/dist/*"
- ssh [email protected] ". /var/www/exphewas/ukbiobank/pyvenv/bin/activate && pip uninstall -y exphewas && pip install /var/www/exphewas/ukbiobank/files/exphewas-*.tar.gz"
- ssh [email protected] "tar -C /var/www/exphewas/ukbiobank/frontend/dist -zxvf /var/www/exphewas/ukbiobank/files/frontend_ukbiobank.tar.gz"
- ssh [email protected] "sudo /usr/bin/systemctl start exphewas_ukbiobank.service"
dependencies:
- build:backend
- build:staging:frontend:ukbiobank
needs:
- build:backend
- build:staging:frontend:ukbiobank
environment:
name: staging_ukbiobank
url: http://wkipl-sg-005.statgen.local/exphewas/ukbiobank/
only:
- staging
deploy:production:
stage: deploy
image: fedora:latest
tags:
- deploy
before_script:
- yum install -y openssh-clients rsync
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
- chmod 600 ~/.ssh/known_hosts
script:
- rsync -av deploy.sh dist/exphewas-*.tar.gz frontend/frontend_dist.tar.gz [email protected]:auto_deploy
- ssh [email protected] "auto_deploy/deploy.sh auto_deploy/exphewas-*.tar.gz auto_deploy/frontend_dist.tar.gz /var/www/exphewas /opt/exphewas-pyvenv"
- ssh [email protected] "sudo /usr/bin/systemctl restart httpd.service"
- ssh [email protected] "sudo /usr/bin/systemctl status httpd.service"
- ssh [email protected] "rm -f auto_deploy/*"
dependencies:
- build:backend
- build:production:frontend
needs:
- build:backend
- build:production:frontend
environment:
name: production_ukbiobank
url: https://exphewas.ca/
only:
- deploy