Only build/tag/push images once

Signed-off-by: Rémy Coutable <remy@rymai.me>
This commit is contained in:
Rémy Coutable 2020-02-25 19:06:49 +01:00
parent cc680155e8
commit 611204c382
No known key found for this signature in database
GPG key ID: 98DFFD1C0C62B70B
4 changed files with 73 additions and 8 deletions

View file

@ -6,13 +6,16 @@ stages:
- automation
services:
- docker:dind
- docker:19.03.0-dind
variables:
DOCKER_DRIVER: overlay
DOCKER_DRIVER: overlay2
DOCKER_HOST: tcp://docker:2375
FORCE_BUILD: "false"
before_script:
- docker login -u "gitlab-ci-token" -p "$CI_JOB_TOKEN" "$CI_REGISTRY"
- source scripts/build-helpers.sh
.test_build: &test_build
stage: test
@ -23,6 +26,8 @@ before_script:
- docker build -f "Dockerfile.$1" .
except:
- master
tags:
- docker
.build_and_deploy: &build_and_deploy
stage: build
@ -31,6 +36,8 @@ before_script:
- docker push "$CI_REGISTRY_IMAGE:$CI_JOB_NAME"
only:
- master
tags:
- docker
.test_custom: &test_custom
stage: test
@ -41,14 +48,18 @@ before_script:
- ./scripts/custom-docker-build $1
except:
- master
tags:
- docker
.build_and_deploy_custom: &build_and_deploy_custom
stage: build
script:
- ./scripts/custom-docker-build $CI_JOB_NAME -t "$CI_REGISTRY_IMAGE:$CI_JOB_NAME"
- docker push "$CI_REGISTRY_IMAGE:$CI_JOB_NAME"
- push_if_needed "$CI_REGISTRY_IMAGE:$CI_JOB_NAME"
only:
- master
tags:
- docker
# Tests