forked from kalaksi/docker-mezzanine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
41 lines (37 loc) · 1.15 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
default:
image: docker:20.10
services:
- docker:20.10-dind
stages:
- build
- distribute
variables:
# Empty tag will become the tag "latest".
IMAGE_TAG: ""
build:
stage: build
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
script:
# If not in master, use branch name with any ".x" suffixes removed.
- |
if [ "$CI_COMMIT_BRANCH" != "$CI_DEFAULT_BRANCH" ]; then
IMAGE_TAG=":$(echo "$CI_COMMIT_REF_NAME" | sed 's/\.x$//')"
fi
- docker build --pull -t "${CI_REGISTRY_IMAGE}${IMAGE_TAG}" .
- docker push "${CI_REGISTRY_IMAGE}${IMAGE_TAG}"
distribute:
stage: distribute
before_script:
- docker login -u "$EXT_REGISTRY_USER" -p "$EXT_REGISTRY_PASSWORD" "$EXT_REGISTRY"
script:
- |
if [ "$CI_COMMIT_BRANCH" != "$CI_DEFAULT_BRANCH" ]; then
IMAGE_TAG=":$(echo "$CI_COMMIT_REF_NAME" | sed 's/\.x$//')"
fi
- docker pull "${CI_REGISTRY_IMAGE}${IMAGE_TAG}"
- docker tag "${CI_REGISTRY_IMAGE}${IMAGE_TAG}" "${EXT_REGISTRY_IMAGE}${IMAGE_TAG}"
- docker push "${EXT_REGISTRY_IMAGE}${IMAGE_TAG}"
only:
variables:
- $EXT_REGISTRY