From 16aac71863ea7d499e50f1c2e4332314afb5b334 Mon Sep 17 00:00:00 2001
From: Yannick DAYER <yannick.dayer@idiap.ch>
Date: Fri, 7 Jun 2024 20:41:45 +0200
Subject: [PATCH] meta(CI): automatically select the profile branch.

---
 .gitlab-ci.yml | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 9a47970..552789b 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,4 +1,31 @@
+workflow:
+  rules:
+    - if: $CI_PIPELINE_SOURCE == 'web'
+    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
+    - if: $CI_PIPELINE_SOURCE == 'parent_pipeline'
+    - if: $CI_COMMIT_TAG
+    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
+
 include:
+  # Runs on dev-profile/main in default branch, when merging to the default
+  # branch, and in "tag pipelines".
   - project: bob/dev-profile
     ref: main
     file: gitlab/python.yml
+    rules:
+      - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
+      - if: $CI_COMMIT_TAG
+      - if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH
+  # Runs on dev-profile/develop in other branches (only when manually triggered)
+  # This is useful when trying new dependency pins in dev-profile/develop.
+  - project: bob/dev-profile
+    ref: main
+    file: gitlab/python.yml
+    rules:
+      - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
+        when: never
+      - if: $CI_COMMIT_TAG
+        when: never
+      - if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH
+        when: never
+      - when: always
-- 
GitLab