-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
276 lines (258 loc) · 8.36 KB
/
.gitlab-ci.yml
File metadata and controls
276 lines (258 loc) · 8.36 KB
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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
stages:
- prepare
- build
- test
- deploy-stage-ansible
- deploy-stage-nginx
- deploy-stage-helm
- deploy-prod-ansible
- deploy-prod-nginx
- deploy-prod-helm
.manual-web:
rules:
- if: $CI_PIPELINE_SOURCE == 'web'
when: manual
allow_failure: true
Assign Docker image tag:
stage: prepare
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
changes:
- Dockerfile
variables:
DOCKER_IMAGE_TAG: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
variables:
DOCKER_IMAGE_TAG: latest
- if: ($CI_PIPELINE_SOURCE != "merge_request_event" && $CI_COMMIT_BRANCH == 'main')
variables:
DOCKER_IMAGE_TAG: latest
script:
- echo "DOCKER_IMAGE_TAG=${DOCKER_IMAGE_TAG}" >> docker.env
artifacts:
reports:
dotenv: docker.env
Build container with Kubernetes and git-crypt:
stage: build
rules:
- !reference [.manual-web, rules]
- if: ($CI_PIPELINE_SOURCE != "schedule" && $CI_COMMIT_BRANCH == 'main') || $CI_PIPELINE_SOURCE == 'merge_request_event'
changes:
- Dockerfile
image: docker-private.gesis.intra/gesis/dc:5.7
services:
- name: docker-private.gesis.intra/gesis/dind:5.5
alias: docker
script:
- docker build --target k8s --no-cache --pull -t docker-private-snapshots.gesis.intra/gesis/ilcm/orc2/k8s:${DOCKER_IMAGE_TAG} .
- docker push docker-private-snapshots.gesis.intra/gesis/ilcm/orc2/k8s:${DOCKER_IMAGE_TAG}
Build container with Ansible and git-crypt:
stage: build
rules:
- !reference [.manual-web, rules]
- if: ($CI_PIPELINE_SOURCE != "schedule" && $CI_COMMIT_BRANCH == 'main') || $CI_PIPELINE_SOURCE == 'merge_request_event'
changes:
- Dockerfile
image: docker-private.gesis.intra/gesis/dc:5.7
services:
- name: docker-private.gesis.intra/gesis/dind:5.5
alias: docker
script:
- docker build --target ansible --no-cache --pull -t docker-private-snapshots.gesis.intra/gesis/ilcm/orc2/ansible:${DOCKER_IMAGE_TAG} .
- docker push docker-private-snapshots.gesis.intra/gesis/ilcm/orc2/ansible:${DOCKER_IMAGE_TAG}
.gesis ansible lint:
stage: test
rules:
- !reference [.manual-web, rules]
- if: (($CI_PIPELINE_SOURCE != "schedule") && $CI_COMMIT_BRANCH == 'main') || $CI_PIPELINE_SOURCE == 'merge_request_event'
changes:
- ansible/**/*
image:
name: docker-private-snapshots.gesis.intra/gesis/ilcm/orc2/ansible:${DOCKER_IMAGE_TAG}
entrypoint: [""]
script:
- ansible-lint --version
- ansible-lint --show-relpath ansible
.gesis ansible deploy:
image:
name: docker-private-snapshots.gesis.intra/gesis/ilcm/orc2/ansible:${DOCKER_IMAGE_TAG}
entrypoint: [""]
variables:
ANSIBLE_INVENTORY: template
script:
- mkdir ~/.ssh/
- echo StrictHostKeyChecking no > ~/.ssh/config
- cp $ANSIBLE_SSH_PUBLIC_KEY ~/.ssh/id_ed25519.pub
- cp $ANSIBLE_SSH_PRIVATE_KEY ~/.ssh/id_ed25519
- chmod 600 ~/.ssh/id_ed25519
- echo $ANSIBLE_VAULT > ansible/.ansible-vault-password-file
- ansible --version
- |
ansible-playbook \
--vault-password-file ansible/.ansible-vault-password-file \
--extra-vars @ansible/vault/${ANSIBLE_INVENTORY}.yml \
--extra-vars "ANSIBLE_CONTROL_NODE_TMP=$(pwd)/tmp" \
--inventory ansible/inventories/${ANSIBLE_INVENTORY} \
--user ansible \
ansible/orc2.yml
.gesis ansible stage deploy:
resource_group: stage
stage: deploy-stage-ansible
rules:
- !reference [.manual-web, rules]
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
changes:
- ansible/**/*
- nginx/**/*
- cron/**/*
variables:
ANSIBLE_INVENTORY: stage
extends:
- .gesis ansible deploy
gesis ansible production deploy:
resource_group: production
stage: deploy-prod-ansible
rules:
- !reference [.manual-web, rules]
- if: $CI_COMMIT_BRANCH == 'main'
changes:
- ansible/**/*
- nginx/**/*
- cron/**/*
variables:
ANSIBLE_INVENTORY: production
extends:
- .gesis ansible deploy
.gesis nginx update with ansible:
image:
name: docker-private-snapshots.gesis.intra/gesis/ilcm/orc2/ansible:${DOCKER_IMAGE_TAG}
entrypoint: [""]
variables:
ANSIBLE_INVENTORY: template
script:
- mkdir ~/.ssh/
- echo StrictHostKeyChecking no > ~/.ssh/config
- cp $ANSIBLE_SSH_PUBLIC_KEY ~/.ssh/id_ed25519.pub
- cp $ANSIBLE_SSH_PRIVATE_KEY ~/.ssh/id_ed25519
- chmod 600 ~/.ssh/id_ed25519
- echo $ANSIBLE_VAULT > ansible/.ansible-vault-password-file
- ansible --version
- |
ansible-playbook \
--vault-password-file ansible/.ansible-vault-password-file \
--extra-vars @ansible/vault/${ANSIBLE_INVENTORY}.yml \
--extra-vars "ANSIBLE_CONTROL_NODE_TMP=$(pwd)/tmp" \
--inventory ansible/inventories/${ANSIBLE_INVENTORY} \
--user ansible \
--tags nginx-config \
ansible/orc2.yml
.gesis nginx update with ansible at stage environment:
resource_group: stage
stage: deploy-stage-nginx
rules:
- !reference [.manual-web, rules]
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
changes:
- helm/charts/gesis/files/etc/binderhub/templates/page.html
- pages/**/*
- nginx/**/*
variables:
ANSIBLE_INVENTORY: stage
extends:
- .gesis nginx update with ansible
gesis nginx update with ansible at stage production:
resource_group: production
stage: deploy-prod-nginx
rules:
- !reference [.manual-web, rules]
- if: $CI_COMMIT_BRANCH == 'main'
changes:
- helm/charts/gesis/files/etc/binderhub/templates/page.html
- pages/**/*
- nginx/**/*
variables:
ANSIBLE_INVENTORY: production
extends:
- .gesis nginx update with ansible
gesis helm lint:
stage: test
rules:
- !reference [.manual-web, rules]
- if: (($CI_PIPELINE_SOURCE != "schedule") && $CI_COMMIT_BRANCH == 'main') || $CI_PIPELINE_SOURCE == 'merge_request_event'
changes:
- helm/**/*
image:
name: docker-private-snapshots.gesis.intra/gesis/ilcm/orc2/k8s:${DOCKER_IMAGE_TAG}
entrypoint: [""]
script:
- helm version
- helm dependency update ./helm/charts/gesis
- helm lint ./helm/charts/gesis
- helm template gesis ./helm/charts/gesis > gesis.helm.chart.yaml
.gesis helm deploy:
image:
name: docker-private-snapshots.gesis.intra/gesis/ilcm/orc2/k8s:${DOCKER_IMAGE_TAG}
entrypoint: [""]
variables:
HELM_ENVIRONMENT: template
script:
- cat $git_crypt_secret_key | base64 -d > git_crypt_secret_key
- git-crypt unlock git_crypt_secret_key
- kubectl config use-context ilcm/orc2:${HELM_ENVIRONMENT}
- helm version
- helm dependency update ./helm/charts/gesis
- |
helm upgrade \
binderhub ./helm/charts/gesis \
--cleanup-on-fail \
--create-namespace \
--history-max 3 \
--install \
--namespace=gesis \
--render-subchart-notes \
--values ./helm/gesis-config/${HELM_ENVIRONMENT}.yaml \
--values ./helm/gesis-config/secrets/values.yaml \
--values ./helm/gesis-config/secrets/ban.yaml \
--values ./helm/gesis-config/secrets/${HELM_ENVIRONMENT}.yaml \
--values ./helm/copy-of-mybinder.org-deploy/secrets/config/common/common.yaml \
--values ./helm/copy-of-mybinder.org-deploy/secrets/config/common/bans.yaml \
--values ./helm/copy-of-mybinder.org-deploy/secrets/config/common/cryptnono.yaml
.gesis helm stage deploy:
resource_group: stage
stage: deploy-stage-helm
rules:
- !reference [.manual-web, rules]
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
changes:
- helm/**/*
variables:
HELM_ENVIRONMENT: stage
extends:
- .gesis helm deploy
gesis helm production deploy:
resource_group: production
stage: deploy-prod-helm
rules:
- !reference [.manual-web, rules]
- if: $CI_PIPELINE_SOURCE != "merge_request_event" && $CI_COMMIT_BRANCH == 'main'
changes:
- helm/**/*
variables:
HELM_ENVIRONMENT: production
extends:
- .gesis helm deploy
pages:
stage: build
rules:
- if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == 'main'
changes:
- docs/**/*
image: docker-private-snapshots.gesis.intra/gesis/methods-hub/quarto:latest
dependencies: []
script:
- quarto check
- quarto render docs -t html --output-dir public
- mv docs/public .
artifacts:
paths:
- public