From 04a9e216929559409b67ef019f120dd73adf556d Mon Sep 17 00:00:00 2001
From: Sebastian Karius <sebastian.karius@informatik.uni-halle.de>
Date: Tue, 7 Jan 2025 15:13:46 +0000
Subject: [PATCH] Update docker-compose.yml

---
 templates/docker-compose.yml | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/templates/docker-compose.yml b/templates/docker-compose.yml
index 4d20c2d..329a254 100644
--- a/templates/docker-compose.yml
+++ b/templates/docker-compose.yml
@@ -16,6 +16,14 @@ spec:
       type: boolean
       default: true
       description: "Build a container with the git tag name as container tag."
+    build_only_protected:
+      type: boolean
+      default: false
+      description: "Build containers only from tags, main branch and protected branches."
+    docker_compose_file:
+      type: string
+      default: "docker-compose.yml"
+      description: "Path to docker compose file."
 
 ---
 "$[[ inputs.job-name ]]":
@@ -35,6 +43,7 @@ spec:
       BUILD_MAIN: $[[ inputs.build_main ]]
       BUILD_BRANCH: $[[ inputs.build_branch ]]
       BUILD_TAG: $[[ inputs.build_tag ]]
+      BUILD_ONLY_PROTECTED: $[[ inputs.build_only_protected ]]
     before_script:
       - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
     script:
@@ -44,14 +53,14 @@ spec:
         elif [[ "$CI_COMMIT_TAG" != '' ]]; then
           export DOCKER_IMAGE_TAG=$CI_COMMIT_TAG
         fi
-      - docker compose build --pull
+      - docker compose build --pull -f $[[ inputs.docker_compose_file ]]
       - docker compose push
     # Run this job in a branch where a docker-compose.yml exists
     rules:
       - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $BUILD_MAIN
         exists:
           - docker-compose.yml
-      - if: $CI_COMMIT_BRANCH && $BUILD_BRANCH
+      - if: $CI_COMMIT_BRANCH && $BUILD_BRANCH && $BUILD_ONLY_PROTECTED == false
         exists:
           - docker-compose.yml
       - if: $CI_COMMIT_TAG && $BUILD_TAG
-- 
GitLab