.gitlab-ci.yml 9.21 KB
Newer Older
1
image: frolvlad/alpine-glibc
2

3 4 5
variables:
  DOCKERHUB_USERNAME: deichman

6
before_script:
7
  - apk add --update --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing make docker curl bash git
8
  - curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
9
  - chmod +x /usr/local/bin/docker-compose
10 11 12

stages:
  - build
Mattias Lundmark's avatar
Mattias Lundmark committed
13
  - push
14
  - deploy
15

16
build-authorization-server:
Magnus Westergaard's avatar
Magnus Westergaard committed
17
  script: make build CONTAINER=authorization-server
18 19 20
  stage: build
  only:
    changes:
21
      - authorization-server/**/*
22

23
build-catalinker:
24
  script:
25
    - make build CONTAINER=catalinker
26
    - make catalinker-test
27
  stage: build
28
  only:
29
    changes:
30
      - catalinker/**/*
31

32
build-deichman.no:
Magnus Westergaard's avatar
Magnus Westergaard committed
33
  script: make build CONTAINER=deichman.no
34 35 36
  stage: build
  only:
    changes:
37
      - deichman.no/**/*
38

39
build-elasticsearch:
Magnus Westergaard's avatar
Magnus Westergaard committed
40
  script: make build CONTAINER=elasticsearch
41 42 43
  stage: build
  only:
    changes:
44
      - elasticsearch/**/*
45 46

build-euler:
Magnus Westergaard's avatar
Magnus Westergaard committed
47
  script: make build CONTAINER=euler
48 49 50 51
  stage: build
  only:
    changes:
      - euler/**/*
52 53

build-katalog:
Magnus Westergaard's avatar
Magnus Westergaard committed
54
  script: make build CONTAINER=katalog
55 56 57 58
  stage: build
  only:
    changes:
      - katalog/**/*
Arnljot Arntsen's avatar
Arnljot Arntsen committed
59

60
build-kibana:
Magnus Westergaard's avatar
Magnus Westergaard committed
61
  script: make build CONTAINER=kibana
62 63 64 65
  stage: build
  only:
    changes:
      - kibana/**/*
66

67
build-koha:
Magnus Westergaard's avatar
Magnus Westergaard committed
68
  script: make build CONTAINER=koha
69 70 71
  stage: build
  only:
    changes:
72
      - koha/**/*
Mattias Lundmark's avatar
Mattias Lundmark committed
73

Magnus Westergaard's avatar
Magnus Westergaard committed
74 75 76 77 78 79 80
build-mimir:
  script: make build CONTAINER=mimir
  stage: build
  only:
    changes:
      - mimir/**/*

Magnus Westergaard's avatar
Magnus Westergaard committed
81
build-resq:
Magnus Westergaard's avatar
Magnus Westergaard committed
82
  script: make build CONTAINER=resq
Magnus Westergaard's avatar
Magnus Westergaard committed
83 84 85 86 87
  stage: build
  only:
    changes:
      - resq/**/*

Magnus Westergaard's avatar
Magnus Westergaard committed
88 89 90 91 92 93 94
build-services:
  script: make build CONTAINER=services
  stage: build
  only:
    changes:
      - services/**/*

Magnus Westergaard's avatar
Magnus Westergaard committed
95
build-sibyl:
Magnus Westergaard's avatar
Magnus Westergaard committed
96
  script: make build CONTAINER=sibyl
Magnus Westergaard's avatar
Magnus Westergaard committed
97 98 99 100 101
  stage: build
  only:
    changes:
      - sibyl/**/*

102
build-testlab-dash:
Magnus Westergaard's avatar
Magnus Westergaard committed
103
  script: make build CONTAINER=testlab-dash
104 105 106
  stage: build
  only:
    changes:
107 108 109 110
      - testlab-dash/**/*

build-timber:
  script:
111
    - make build CONTAINER=timber
112 113 114 115 116 117 118
    - make timber-test
  stage: build
  only:
    changes:
      - timber/**/*

build-tjenestekatalog:
Magnus Westergaard's avatar
Magnus Westergaard committed
119
  script: make build CONTAINER=tjenestekatalog
120 121 122 123
  stage: build
  only:
    changes:
      - tjenestekatalog/**/*
124

Magnus Westergaard's avatar
Magnus Westergaard committed
125
deploy-test:
126
  before_script:
127
    - 'which ssh-agent || ( apk add --update --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing openssh-client git )'
128 129 130 131 132 133
    - eval $(ssh-agent -s)
    - echo "$TEST_KEY" | tr -d '\r' | ssh-add - > /dev/null
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
    - echo "$TEST_KNOWN_HOSTS" > ~/.ssh/known_hosts
    - chmod 644 ~/.ssh/known_hosts
Magnus Westergaard's avatar
Magnus Westergaard committed
134
  script: ssh $TEST_DEPLOY_USER@$TEST_DEPLOY_SERVER "cd deployment-config && git pull && cd test && ./deploy.sh test-1 $APPLICATION_NAME"
135 136
  stage: deploy
  when: manual
137

138
deploy-authorization-server-test:
Magnus Westergaard's avatar
Magnus Westergaard committed
139
  extends: deploy-test
Magnus Westergaard's avatar
Magnus Westergaard committed
140 141 142
  only: { changes: ['authorization-server/**/*'] }
  variables:
    APPLICATION_NAME: authorization-server
143 144

deploy-catalinker-test:
Magnus Westergaard's avatar
Magnus Westergaard committed
145
  extends: deploy-test
Magnus Westergaard's avatar
Magnus Westergaard committed
146 147 148
  only: { changes: ['catalinker/**/*'] }
  variables:
    APPLICATION_NAME: catalinker
149 150

deploy-deichman_no-test:
Magnus Westergaard's avatar
Magnus Westergaard committed
151
  extends: deploy-test
Magnus Westergaard's avatar
Magnus Westergaard committed
152 153 154
  only: { changes: ['deichman.no/**/*'] }
  variables:
    APPLICATION_NAME: deichman.no
155 156

deploy-elasticsearch-test:
Magnus Westergaard's avatar
Magnus Westergaard committed
157
  extends: deploy-test
Magnus Westergaard's avatar
Magnus Westergaard committed
158 159 160
  only: { changes: ['elasticsearch/**/*'] }
  variables:
    APPLICATION_NAME: elasticsearch
161 162

deploy-euler-test:
Magnus Westergaard's avatar
Magnus Westergaard committed
163
  extends: deploy-test
Magnus Westergaard's avatar
Magnus Westergaard committed
164 165 166
  only: { changes: ['euler/**/*'] }
  variables:
    APPLICATION_NAME: euler
167 168

deploy-katalog-test:
Magnus Westergaard's avatar
Magnus Westergaard committed
169
  extends: deploy-test
Magnus Westergaard's avatar
Magnus Westergaard committed
170 171 172
  only: { changes: ['katalog/**/*'] }
  variables:
    APPLICATION_NAME: katalog
173 174

deploy-kibana-test:
Magnus Westergaard's avatar
Magnus Westergaard committed
175
  extends: deploy-test
Magnus Westergaard's avatar
Magnus Westergaard committed
176 177 178
  only: { changes: ['kibana/**/*'] }
  variables:
    APPLICATION_NAME: kibana
179 180

deploy-koha-test:
Magnus Westergaard's avatar
Magnus Westergaard committed
181
  extends: deploy-test
Magnus Westergaard's avatar
Magnus Westergaard committed
182 183 184
  only: { changes: ['koha/**/*'] }
  variables:
    APPLICATION_NAME: koha
185 186

deploy-mimir-test:
Magnus Westergaard's avatar
Magnus Westergaard committed
187
  extends: deploy-test
Magnus Westergaard's avatar
Magnus Westergaard committed
188 189 190
  only: { changes: ['mimir/**/*'] }
  variables:
    APPLICATION_NAME: mimir
191 192

deploy-resq-test:
Magnus Westergaard's avatar
Magnus Westergaard committed
193
  extends: deploy-test
Magnus Westergaard's avatar
Magnus Westergaard committed
194 195 196
  only: { changes: ['resq/**/*'] }
  variables:
    APPLICATION_NAME: resq
197 198

deploy-services-test:
Magnus Westergaard's avatar
Magnus Westergaard committed
199
  extends: deploy-test
Magnus Westergaard's avatar
Magnus Westergaard committed
200 201 202
  only: { changes: ['services/**/*'] }
  variables:
    APPLICATION_NAME: services
203 204

deploy-sibyl-test:
Magnus Westergaard's avatar
Magnus Westergaard committed
205
  extends: deploy-test
Magnus Westergaard's avatar
Magnus Westergaard committed
206 207 208
  only: { changes: ['sibyl/**/*'] }
  variables:
    APPLICATION_NAME: sibyl
209 210

deploy-testlab-dash-test:
Magnus Westergaard's avatar
Magnus Westergaard committed
211
  extends: deploy-test
Magnus Westergaard's avatar
Magnus Westergaard committed
212 213 214
  only: { changes: ['testlab-dash/**/*'] }
  variables:
    APPLICATION_NAME: testlab-dash
215 216

deploy-timber-test:
Magnus Westergaard's avatar
Magnus Westergaard committed
217
  extends: deploy-test
Magnus Westergaard's avatar
Magnus Westergaard committed
218 219 220
  only: { changes: ['timber/**/*'] }
  variables:
    APPLICATION_NAME: timber
221 222

deploy-tjenestekatalog-test:
Magnus Westergaard's avatar
Magnus Westergaard committed
223
  extends: deploy-test
Magnus Westergaard's avatar
Magnus Westergaard committed
224 225 226
  only: { changes: ['tjenestekatalog/**/*'] }
  variables:
    APPLICATION_NAME: tjenestekatalog
227

Magnus Westergaard's avatar
Magnus Westergaard committed
228
integration-tests:
Magnus Westergaard's avatar
Magnus Westergaard committed
229 230
  script:
    - cd integration-tests
Magnus Westergaard's avatar
Magnus Westergaard committed
231
    - docker-compose -p $CI_PIPELINE_IID -f docker-compose-common.yml -f docker-compose-ci.yml up --build --exit-code-from tests
Magnus Westergaard's avatar
Magnus Westergaard committed
232
  after_script:
Magnus Westergaard's avatar
Magnus Westergaard committed
233
    - cd integration-tests
Magnus Westergaard's avatar
Magnus Westergaard committed
234
    - docker-compose -p $CI_PIPELINE_IID -f docker-compose-common.yml -f docker-compose-ci.yml down -v
Magnus Westergaard's avatar
Magnus Westergaard committed
235
  artifacts:
Magnus Westergaard's avatar
Magnus Westergaard committed
236
    when: always
Magnus Westergaard's avatar
Magnus Westergaard committed
237 238
    expire_in: 1 week
    paths:
Magnus Westergaard's avatar
Magnus Westergaard committed
239 240
      - integration-tests/cypress/videos/
      - integration-tests/cypress/screenshots/
Magnus Westergaard's avatar
Magnus Westergaard committed
241
  stage: build
Magnus Westergaard's avatar
Magnus Westergaard committed
242 243 244
  only:
    - schedules

245
# Push stages here
Magnus Westergaard's avatar
Magnus Westergaard committed
246 247
.push-latest:
  script: make push CONTAINER=$APPLICATION_NAME
Mattias Lundmark's avatar
Mattias Lundmark committed
248
  stage: push
Mattias Lundmark's avatar
Mattias Lundmark committed
249
  when: manual
Mattias Lundmark's avatar
Mattias Lundmark committed
250

Magnus Westergaard's avatar
Magnus Westergaard committed
251 252
.push-tag:
  script: make push CONTAINER=$APPLICATION_NAME TAG=$CI_COMMIT_TAG NOCACHE=--no-cache
253 254 255 256
  stage: push
  only:
    - tags

Magnus Westergaard's avatar
Magnus Westergaard committed
257 258 259 260 261 262 263 264 265 266 267
push-authorization-server-latest:
  extends: .push-latest
  only: { changes: ['authorization-server/**/*'] }
  variables:
    APPLICATION_NAME: authorization-server

push-authorization-server-tag:
  extends: .push-tag
  variables:
    APPLICATION_NAME: authorization-server

268
push-catalinker-latest:
Magnus Westergaard's avatar
Magnus Westergaard committed
269 270 271 272
  extends: .push-latest
  only: { changes: ['catalinker/**/*'] }
  variables:
    APPLICATION_NAME: catalinker
273

274
push-catalinker-tag:
Magnus Westergaard's avatar
Magnus Westergaard committed
275 276 277
  extends: .push-tag
  variables:
    APPLICATION_NAME: catalinker
Mattias Lundmark's avatar
Mattias Lundmark committed
278

279
push-deichman.no-latest:
Magnus Westergaard's avatar
Magnus Westergaard committed
280 281 282 283
  extends: .push-latest
  only: { changes: ['deichman.no/**/*'] }
  variables:
    APPLICATION_NAME: deichman.no
Mattias Lundmark's avatar
Mattias Lundmark committed
284

285
push-deichman.no-tag:
Magnus Westergaard's avatar
Magnus Westergaard committed
286 287 288
  extends: .push-tag
  variables:
    APPLICATION_NAME: deichman.no
Mattias Lundmark's avatar
Mattias Lundmark committed
289

290
push-elasticsearch-latest:
Magnus Westergaard's avatar
Magnus Westergaard committed
291 292 293 294
  extends: .push-latest
  only: { changes: ['elasticsearch/**/*'] }
  variables:
    APPLICATION_NAME: elasticsearch
Mattias Lundmark's avatar
Mattias Lundmark committed
295

296
push-elasticsearch-tag:
Magnus Westergaard's avatar
Magnus Westergaard committed
297 298 299
  extends: .push-tag
  variables:
    APPLICATION_NAME: elasticsearch
Mattias Lundmark's avatar
Mattias Lundmark committed
300 301

push-euler-latest:
Magnus Westergaard's avatar
Magnus Westergaard committed
302 303 304 305
  extends: .push-latest
  only: { changes: ['euler/**/*'] }
  variables:
    APPLICATION_NAME: euler
Mattias Lundmark's avatar
Mattias Lundmark committed
306 307

push-euler-tag:
Magnus Westergaard's avatar
Magnus Westergaard committed
308 309 310
  extends: .push-tag
  variables:
    APPLICATION_NAME: euler
Mattias Lundmark's avatar
Mattias Lundmark committed
311 312

push-katalog-latest:
Magnus Westergaard's avatar
Magnus Westergaard committed
313 314 315 316
  extends: .push-latest
  only: { changes: ['katalog/**/*'] }
  variables:
    APPLICATION_NAME: katalog
Mattias Lundmark's avatar
Mattias Lundmark committed
317 318

push-katalog-tag:
Magnus Westergaard's avatar
Magnus Westergaard committed
319 320 321
  extends: .push-tag
  variables:
    APPLICATION_NAME: katalog
Mattias Lundmark's avatar
Mattias Lundmark committed
322

323
push-kibana-latest:
Magnus Westergaard's avatar
Magnus Westergaard committed
324 325 326 327
  extends: .push-latest
  only: { changes: ['kibana/**/*'] }
  variables:
    APPLICATION_NAME: kibana
Magnus Westergaard's avatar
Magnus Westergaard committed
328

329
push-kibana-tag:
Magnus Westergaard's avatar
Magnus Westergaard committed
330 331 332
  extends: .push-tag
  variables:
    APPLICATION_NAME: kibana
Magnus Westergaard's avatar
Magnus Westergaard committed
333

334
push-koha-latest:
335
  script:
336 337
    - docker-compose build --build-arg BUILD_DATE="$BUILD_DATE" --build-arg HISTORY="$HISTORY" koha
    - docker tag deichman_koha digibib/kaffe:latest
338
    - docker login --username=$DOCKERHUB_USERNAME --password=$DOCKERHUB_PASSWORD
339
    - docker push digibib/kaffe:latest
340 341 342
  stage: push
  only:
    changes:
343
      - koha/**/*
344 345
  when: manual

346
push-koha-tag:
Mattias Lundmark's avatar
Mattias Lundmark committed
347
  script:
348 349 350
    - docker-compose build --build-arg BUILD_DATE="$BUILD_DATE" --build-arg HISTORY="$HISTORY" --no-cache koha
    - docker tag deichman_koha digibib/kaffe:latest
    - docker tag deichman_koha digibib/kaffe:$CI_COMMIT_TAG
351
    - docker login --username=$DOCKERHUB_USERNAME --password=$DOCKERHUB_PASSWORD
352 353 354 355 356 357 358
    - docker push digibib/kaffe:latest
    - docker push digibib/kaffe:$CI_COMMIT_TAG
  stage: push
  only:
    - tags

push-mimir-latest:
Magnus Westergaard's avatar
Magnus Westergaard committed
359 360 361 362
  extends: .push-latest
  only: { changes: ['mimir/**/*'] }
  variables:
    APPLICATION_NAME: mimir
363

364
push-mimir-tag:
Magnus Westergaard's avatar
Magnus Westergaard committed
365 366 367
  extends: .push-tag
  variables:
    APPLICATION_NAME: mimir
Mattias Lundmark's avatar
Mattias Lundmark committed
368

369
push-resq-latest:
Magnus Westergaard's avatar
Magnus Westergaard committed
370 371 372 373
  extends: .push-latest
  only: { changes: ['resq/**/*'] }
  variables:
    APPLICATION_NAME: resq
374

375
push-resq-tag:
Magnus Westergaard's avatar
Magnus Westergaard committed
376 377 378
  extends: .push-tag
  variables:
    APPLICATION_NAME: resq
Mattias Lundmark's avatar
Mattias Lundmark committed
379

380
push-services-latest:
Magnus Westergaard's avatar
Magnus Westergaard committed
381 382 383 384
  extends: .push-latest
  only: { changes: ['services/**/*'] }
  variables:
    APPLICATION_NAME: services
385 386

push-services-tag:
Magnus Westergaard's avatar
Magnus Westergaard committed
387 388 389
  extends: .push-tag
  variables:
    APPLICATION_NAME: services
390 391

push-sibyl-latest:
Magnus Westergaard's avatar
Magnus Westergaard committed
392 393 394 395
  extends: .push-latest
  only: { changes: ['sibyl/**/*'] }
  variables:
    APPLICATION_NAME: sibyl
396 397

push-sibyl-tag:
Magnus Westergaard's avatar
Magnus Westergaard committed
398 399 400
  extends: .push-tag
  variables:
    APPLICATION_NAME: sibyl
401

402
push-testlab-dash-latest:
Magnus Westergaard's avatar
Magnus Westergaard committed
403 404 405 406
  extends: .push-latest
  only: { changes: ['testlab-dash/**/*'] }
  variables:
    APPLICATION_NAME: testlab-dash
407 408

push-testlab-dash-tag:
Magnus Westergaard's avatar
Magnus Westergaard committed
409 410 411
  extends: .push-tag
  variables:
    APPLICATION_NAME: testlab-dash
412 413

push-timber-latest:
Magnus Westergaard's avatar
Magnus Westergaard committed
414 415 416 417
  extends: .push-latest
  only: { changes: ['timber/**/*'] }
  variables:
    APPLICATION_NAME: timber
418 419

push-timber-tag:
Magnus Westergaard's avatar
Magnus Westergaard committed
420 421 422
  extends: .push-tag
  variables:
    APPLICATION_NAME: timber
423 424

push-tjenestekatalog-latest:
Magnus Westergaard's avatar
Magnus Westergaard committed
425 426 427 428
  extends: .push-latest
  only: { changes: ['tjenestekatalog/**/*'] }
  variables:
    APPLICATION_NAME: tjenestekatalog
429 430

push-tjenestekatalog-tag:
Magnus Westergaard's avatar
Magnus Westergaard committed
431 432 433
  extends: .push-tag
  variables:
    APPLICATION_NAME: tjenestekatalog