From e8511d54228521f6c6b2fdd4daed3d0c1c03d7cd Mon Sep 17 00:00:00 2001
From: Moul <moul@moul.re>
Date: Fri, 10 Mar 2023 17:22:32 +0100
Subject: [PATCH] ci: Present docker jobs available only if based on a
 protected reference
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Regarding jobs:
- deploy_docker_test_image
- deploy_docker_release_sha
it doesn’t make sense to have these jobs available since
it will fail with DockerHub password missing since it’s not
running on a protected branch or tag

Brought some difficulty https://forum.duniter.org/t//10164/17

https://stackoverflow.com/questions/54901151/how-do-i-configure-gitlab-ci-jobs-to-run-on-protected-branches-only
---
 .gitlab-ci.yml | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index df81ca2e2..57fbe79f7 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -231,6 +231,8 @@ tests_release:
 deploy_docker_test_image:
   extends: .docker-build-app-image
   rules:
+    - if: $CI_COMMIT_REF_PROTECTED == "false"
+      when: never
     - if: $CI_COMMIT_REF_NAME =~ /^wip*$/
       when: manual
     - if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH == "master"'
@@ -261,6 +263,8 @@ deploy_docker_debug_sha:
 deploy_docker_release_sha:
   extends: .docker-build-app-image
   rules:
+    - if: $CI_COMMIT_REF_PROTECTED == "false"
+      when: never
     - if: $CI_COMMIT_TAG
       when: never
     - when: manual
@@ -305,4 +309,3 @@ readme_docker_release_tag:
     PUSHRM_DEBUG: 1
     PUSHRM_FILE: "$CI_PROJECT_DIR/docker/README.md"
   script: "/bin/true"
-
-- 
GitLab