-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
89 lines (81 loc) · 2.94 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
variables:
COMPOSE_FILE: "docker-compose.build.yml"
CONTAINER_BUILD_IMAGE: "cliup-build-app"
CONTAINER_RELEASE_IMAGE: "nanawel/cliup"
CONTAINER_PUBLIC_IMAGE: "nanawel/cliup"
stages:
- build
- test
- release
before_script:
- time docker info
- '[ -z "${REGISTRY_SERVER}" ] || time docker login ${REGISTRY_SERVER}'
- env | sort
build_image:
stage: build
script:
- time make config
- export buildVersion=$([ -z "${CI_COMMIT_TAG}" ] && echo ${CI_COMMIT_REF_SLUG} || echo ${CI_COMMIT_TAG})
&& time make build args="--build-arg build_version=${buildVersion} --build-arg build_id=${CI_COMMIT_SHORT_SHA} --build-arg build_date=$(date -Is)"
- time docker tag ${CONTAINER_BUILD_IMAGE}:${APP_VERSION:-latest} ${CONTAINER_RELEASE_IMAGE}:${CI_COMMIT_SHORT_SHA}
- time docker push ${CONTAINER_RELEASE_IMAGE}:${CI_COMMIT_SHORT_SHA}
tags:
- shell
- docker
hurl_test:
stage: test
script:
- time make test-docker rebuild=1 ENCRYPTION_ENABLED=0
- time make test-docker rebuild=0 ENCRYPTION_ENABLED=1
tags:
- shell
- docker
push_image_dev_latest:
stage: release
script:
- time docker pull ${CONTAINER_RELEASE_IMAGE}:${CI_COMMIT_SHORT_SHA}
- time docker tag ${CONTAINER_RELEASE_IMAGE}:${CI_COMMIT_SHORT_SHA} ${CONTAINER_RELEASE_IMAGE}:latest-dev
- time docker push ${CONTAINER_RELEASE_IMAGE}:latest-dev
tags:
- shell
- docker
rules:
- if: '$CI_COMMIT_BRANCH =~ /^feature\//'
push_image_latest:
stage: release
script:
- time docker pull ${CONTAINER_RELEASE_IMAGE}:${CI_COMMIT_SHORT_SHA}
- time docker tag ${CONTAINER_RELEASE_IMAGE}:${CI_COMMIT_SHORT_SHA} ${CONTAINER_RELEASE_IMAGE}:latest
- time docker push ${CONTAINER_RELEASE_IMAGE}:latest
tags:
- shell
- docker
rules:
- if: '$CI_COMMIT_BRANCH == "main"'
- if: '$CI_COMMIT_BRANCH == "master"'
push_image_tagged:
stage: release
script:
- time docker pull ${CONTAINER_RELEASE_IMAGE}:${CI_COMMIT_SHORT_SHA}
- time docker tag ${CONTAINER_RELEASE_IMAGE}:${CI_COMMIT_SHORT_SHA} ${CONTAINER_RELEASE_IMAGE}:${CI_COMMIT_TAG}
- time docker push ${CONTAINER_RELEASE_IMAGE}:${CI_COMMIT_TAG}
tags:
- shell
- docker
rules:
- if: '$CI_COMMIT_TAG =~ /^\d+\.\d+\.\d+(-\w+)?$/'
push_image_public:
stage: release
script:
- docker login -u "${PUBLIC_REGISTRY_USERNAME}" -p "${PUBLIC_REGISTRY_TOKEN}"
- time docker pull ${CONTAINER_RELEASE_IMAGE}:${CI_COMMIT_SHORT_SHA}
- time docker tag ${CONTAINER_RELEASE_IMAGE}:${CI_COMMIT_SHORT_SHA} ${CONTAINER_PUBLIC_IMAGE}:latest
- time docker push ${CONTAINER_PUBLIC_IMAGE}:latest
- '[ -z "${CI_COMMIT_TAG}" ] || time docker tag ${CONTAINER_RELEASE_IMAGE}:${CI_COMMIT_SHORT_SHA} ${CONTAINER_PUBLIC_IMAGE}:${CI_COMMIT_TAG}'
- '[ -z "${CI_COMMIT_TAG}" ] || time docker push ${CONTAINER_PUBLIC_IMAGE}:${CI_COMMIT_TAG}'
tags:
- shell
- docker
rules:
- when: manual
if: '$CONTAINER_RELEASE_IMAGE != $CONTAINER_PUBLIC_IMAGE'