-
Notifications
You must be signed in to change notification settings - Fork 24
/
.gitlab-ci.yml
40 lines (36 loc) · 1.17 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
default:
image: docker:27.0
services:
- docker:27.0-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"
- docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- docker buildx create --use
script:
# If not in master, use branch name with ".x" suffix removed.
- |
if [ "$CI_COMMIT_BRANCH" != "$CI_DEFAULT_BRANCH" ]; then
IMAGE_TAG=":$(echo "$CI_COMMIT_REF_NAME" | sed 's/\.x$//')"
fi
- docker buildx build --platform linux/amd64,linux/arm64 --pull --push -t "${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 buildx imagetools create -t "${EXT_REGISTRY_IMAGE}${IMAGE_TAG}" "${CI_REGISTRY_IMAGE}${IMAGE_TAG}"
only:
variables:
- $EXT_REGISTRY