forked from nanawel/reciphpes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
64 lines (58 loc) · 2.02 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
variables:
CONTAINER_RELEASE_IMAGE: "nanawel/reciphpes"
CONTAINER_PUBLIC_IMAGE: "nanawel/reciphpes"
stages:
- check
- build
- release
before_script:
- time docker info
- '[ -z "${REGISTRY_SERVER}" ] || time docker login ${REGISTRY_SERVER}'
- env
build_image:
stage: build
script:
- time make build
- time docker tag reciphpes:${WEBAPP_VERSION:-latest} ${CONTAINER_RELEASE_IMAGE}:${CI_COMMIT_SHORT_SHA}
- time docker push ${CONTAINER_RELEASE_IMAGE}:${CI_COMMIT_SHORT_SHA}
tags:
- shell
- docker
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+$/'
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'