From 3044b11c06361d5697319213da702134b9cac8ea Mon Sep 17 00:00:00 2001
From: Etienne Loupias <eloupias@grandlyon.com>
Date: Tue, 19 Nov 2024 10:47:39 +0100
Subject: [PATCH] ci: optional manual MR build and deploy

---
 .gitlab-ci.yml | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 7cf788788..259a7d8af 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -18,8 +18,14 @@ variables:
 
 build:
   stage: build
-  only:
-    - dev
+  rules:
+    # Always run the stage for the 'dev' branch
+    - if: '$CI_COMMIT_REF_NAME == "dev"'
+    # For Merge Requests, make the stage manual
+    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
+      when: manual
+    # Otherwise, skip the stage
+    - when: never    
   needs: []
   variables:
     DOCKER_TLS_CERTDIR: ''
@@ -188,8 +194,14 @@ db-copy-20-rec:
 
 deploy-10-dev:
   stage: deploy
-  only:
-    - dev
+  rules:
+    # Always run the stage for the 'dev' branch
+    - if: '$CI_COMMIT_REF_NAME == "dev"'
+    # For Merge Requests, make the stage manual
+    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
+      when: manual
+    # Otherwise, skip the stage
+    - when: never    
   needs: ['test', 'build']
   inherit:
     default: [before_script]
-- 
GitLab