-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
25 lines (24 loc) · 1006 Bytes
/
.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
---
stages:
- build
build:
stage: build
rules:
# Build a new backend version if git tag looks like "1.2" or "1.2-something"
- if: '$CI_COMMIT_TAG =~ /^\d+(\.\d+)*(-[-0-9A-Za-z_.]+)?$/'
script:
## If $CI_COMMIT_TAG contains additional tags (e.g. "1.1-template-blah"),
## extract them and pass as build argument to Docker (e.g. "TAGS=template,blah")
# - >
# if [[ "$CI_COMMIT_TAG" =~ ^[^-]+-.+$ ]]; then
# TAGS_PRE="${CI_COMMIT_TAG#*-}";
# TAGS="${TAGS_PRE//-/,}";
# else
# unset TAGS;
# fi
## Or, more simple approach (if you want to use in git tag
## some words which does not map to Go build tags)
- TAGS=$(echo "$CI_COMMIT_TAG" | grep -qEe '-(tmpl|template)' && echo template)
- docker build . -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG" "${TAGS:+--build-arg=TAGS=$TAGS}"
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
- docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG"