ci: Rework workflow rules to prevent duplicate pipelines
authorJordan Petridis <jordan@centricular.com>
Wed, 29 Sep 2021 12:15:03 +0000 (15:15 +0300)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Tue, 5 Oct 2021 11:49:01 +0000 (11:49 +0000)
Currently gitlab spawns 2 pipelines, one for the branch and
another for the merge request.

Update our rules so that only one of them is spawned depending
on the situation.

https://docs.gitlab.com/ee/ci/yaml/index.html#switch-between-branch-pipelines-and-merge-request-pipelines

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/958>

.gitlab-ci.yml

index 69ab3e9..8e7a44d 100644 (file)
@@ -81,10 +81,12 @@ variables:
     -Dgstreamer-sharp:werror=true
 
 workflow:
+  # https://docs.gitlab.com/ee/ci/yaml/index.html#switch-between-branch-pipelines-and-merge-request-pipelines
   rules:
-    - if: $CI_MERGE_REQUEST_IID
-    - if: $CI_COMMIT_TAG
-    - if: $CI_COMMIT_BRANCH
+    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
+    - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS && $CI_PIPELINE_SOURCE == "push"
+      when: never
+    - if: '$CI_COMMIT_BRANCH'
 
 #
 # Global CI policy