-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
26 lines (25 loc) · 1.24 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
# Example GitLab CI/CD configuration
#
# Simple CI/CD configuration that first builds a docker image including the
# configuration, and then runs the validation inside a docker container. When
# successfull, the docker image is uploaded to the container registry
build_docker_image_and_validate:
stage: build
image: docker:20
services:
- docker:20-dind
script:
- echo -e "\e[96m\e[1mVerify Tag Format\e[0m"
- "echo $CI_COMMIT_TAG | grep -oE '^([0-9]+\\.){2}[0-9]+$' || (echo \"ERROR: Invalid tag format, should be a three part version number (e.g. 1.2.3)\" && exit 1)"
- echo -e "\e[96m\e[1mBuild Docker Image\e[0m"
- IMAGE_TAG=$(echo "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG" | tr [:upper:] [:lower:])
- docker build . -t $IMAGE_TAG
- echo -e "\e[96m\e[1mValidate Configuration\e[0m"
- docker run --rm $IMAGE_TAG python validate.py
- echo -e "\e[96m\e[1mPush Docker Image\e[0m"
- echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER $CI_REGISTRY --password-stdin
- 'if docker pull $IMAGE_TAG > /dev/null 2>&1; then echo "ERROR: An image with the given tag already exists. Please increment the contents of the VERSION file" && exit 1; fi'
- docker push $IMAGE_TAG
only:
- tags
timeout: 5 minutes