From 9f720fb8f769687e342af1c6db83179c1e2af0ee Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@collabora.com>
Date: Tue, 8 Jun 2021 17:23:56 +0100
Subject: [PATCH] Don't automatically run CI for pushes to master

When we push to master it's usually for one of three reasons:

1. We merged a merge request
2. We pushed the "release vX.Y.Z" commit, together with a tag
3. We pushed some other trivial change directly

When we merged a merge request, immediately running CI is not
necessarily very helpful, because we already ran it for the branch
that's getting merged.

If we pushed a release commit and a tag, we want the CI pipeline for
the tag to take priority over the CI pipeline for the release commit.

If we pushed a trivial change, it might not even need CI (if it's just
a change to a README, or similar), but if it does, we can trigger it
manually.

Signed-off-by: Simon McVittie <smcv@collabora.com>
---
 debian/gitlab-ci.yml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/debian/gitlab-ci.yml b/debian/gitlab-ci.yml
index a9f68b9fc..a53fcfb13 100644
--- a/debian/gitlab-ci.yml
+++ b/debian/gitlab-ci.yml
@@ -75,6 +75,8 @@ workflow:
     rules:
         - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
           when: never
+        - if: '$CI_COMMIT_BRANCH == "master" && $CI_PIPELINE_SOURCE == "push"'
+          when: never
         - when: always
 
 stages:
-- 
GitLab