Only build (and upload) the docker image if we are on master.

This commit is contained in:
Phil Elson 2021-07-07 10:58:39 +02:00
parent d4225a9d4f
commit f33f2a4cbc

View file

@ -43,13 +43,12 @@ deploy_to_test:
oci_calculator:
# A convenient way for users to run the CARA calculator.
stage: deploy
rules:
# Only run if branch is master (the default branch).
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
image:
name: gitlab-registry.cern.ch/ci-tools/docker-image-builder
entrypoint: [""]
script:
# Prepare Kaniko configuration file
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
# Build and push the image from the Dockerfile at the root of the project.
# To push to a specific docker tag, amend the --destination parameter, e.g. --destination $CI_REGISTRY_IMAGE:$CI_BUILD_REF_NAME
# See https://docs.gitlab.com/ee/ci/variables/predefined_variables.html#variables-reference for available variables
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE/calculator:latest