-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
57 lines (51 loc) · 1.91 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
include:
- project: 'docker/process-webhooks'
file: '/gitlab/deploy.yml'
variables:
PROJECT_TO_BE_DEPLOYED: 'docker/translation-memory-tools'
image: docker/compose:latest
services:
- docker:dind
stages:
- build
- test
- publish
- deploy
build:
stage: build
before_script:
- apk add --no-cache git
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- echo $(date +%Y%m%d-%H%M%S) > $CI_PROJECT_DIR/datetag.txt
- export DATETAG=$(cat $CI_PROJECT_DIR/datetag.txt)
- echo "CI_REGISTRY_IMAGE:CI_COMMIT_REF_NAME->" $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
- echo "CI_REGISTRY_IMAGE:$DATETAG->" $CI_REGISTRY_IMAGE:$DATETAG
- cp docker/dockerfile-webapp docker/dockerfile-webapp-local
- sed -i "s+tmt-data+registry.softcatala.org/github/translation-memory-tools/tmt-data:$CI_COMMIT_REF_NAME+g" docker/dockerfile-webapp-local
- docker build --tag tmt-webapp --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME --tag $CI_REGISTRY_IMAGE:$DATETAG . -f docker/dockerfile-webapp-local
artifacts:
paths:
- datetag.txt
test:
stage: test
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- cp docker/dockerfile-webapp-test docker/dockerfile-webapp-test-local
- sed -i "s+tmt-data+registry.softcatala.org/github/translation-memory-tools/tmt-data:$CI_COMMIT_REF_NAME+g" docker/dockerfile-webapp-test-local
- docker build --tag tmt-webapp-test . -f docker/dockerfile-webapp-test-local
- docker run -t tmt-webapp-test
publish:
stage: publish
before_script:
- apk add --no-cache git
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- export DATETAG=$(cat $CI_PROJECT_DIR/datetag.txt)
- docker push $CI_REGISTRY_IMAGE:$DATETAG
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
deploy:
stage: deploy
extends:
.default-deploy