Skip to content
Snippets Groups Projects
Commit 35502d41 authored by Sebastian Karius's avatar Sebastian Karius
Browse files

Add conditional inputs for Docker build configurations

parent d9f8208b
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,19 @@ spec:
inputs:
stage:
default: build
build_main:
type: boolean
default: true
description: "Build a container with the 'latest' container tag from the default (main) branch."
build_branch:
type: boolean
default: true
description: "Build a container with the branch name (except for default branch) as container tag."
build_tag:
type: boolean
default: true
description: "Build a container with the git tag name as container tag."
---
docker-compose-build:
# Use the official docker image.
......@@ -21,7 +34,7 @@ docker-compose-build:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- |
if [[ "$CI_COMMIT_BRANCH" == 'main' ]]; then
if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then
export DOCKER_IMAGE_TAG=latest
elif [[ "$CI_COMMIT_TAG" != '' ]]; then
export DOCKER_IMAGE_TAG=$CI_COMMIT_TAG
......@@ -30,9 +43,12 @@ docker-compose-build:
- docker compose push
# Run this job in a branch where a docker-compose.yml exists
rules:
- if: $CI_COMMIT_BRANCH
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $[[ inputs.build_main ]]
exists:
- docker-compose.yml
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH && $[[ inputs.build_branch ]]
exists:
- docker-compose.yml
- if: $CI_COMMIT_TAG && $[[ inputs.build_tag ]]
exists:
- docker-compose.yml
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment