From 81dc34ec683ee0977ec557ac8ddeb145873cd7d6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marcel=20M=C3=A4rtens?= <marcel.cochem@googlemail.com>
Date: Thu, 8 Jul 2021 11:27:44 +0200
Subject: [PATCH] test on merge event rather than branch name master as a fork
 could also have a branch master

---
 .gitlab/CI/recompile.yml | 2 +-
 .gitlab/CI/release.yml   | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/.gitlab/CI/recompile.yml b/.gitlab/CI/recompile.yml
index c366dfe40a..c748ca254d 100644
--- a/.gitlab/CI/recompile.yml
+++ b/.gitlab/CI/recompile.yml
@@ -1,7 +1,7 @@
 # Template to only run if actual changes has been made to the code and not just documentation
 .recompile-branch:
   rules:
-    - if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
+    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
       # No '-' here is *very* important: https://docs.gitlab.com/ee/ci/yaml/#complex-rule-clauses
       changes:
         - "**/*.{glsl,png,rs,ron,toml,vox,yml,wav}"
diff --git a/.gitlab/CI/release.yml b/.gitlab/CI/release.yml
index 68b2a10f7f..4622002b85 100644
--- a/.gitlab/CI/release.yml
+++ b/.gitlab/CI/release.yml
@@ -2,7 +2,7 @@
 .optional-release:
   stage: check
   rules:
-    - if: $CI_PIPELINE_SOURCE == "schedule" || $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+/ || $CI_COMMIT_REF_NAME =~ /^r[0-9]+\.[0-9]+/
+    - if: $CI_PIPELINE_SOURCE != "merge_request_event" || $CI_PIPELINE_SOURCE == "schedule" || $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+/ || $CI_COMMIT_REF_NAME =~ /^r[0-9]+\.[0-9]+/
       when: never
     - when: manual
       allow_failure: true
@@ -11,7 +11,7 @@
 .release:
   stage: build
   rules:
-    - if: $CI_PIPELINE_SOURCE != "schedule" && ($CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+/ || $CI_COMMIT_REF_NAME =~ /^r[0-9]+\.[0-9]+/)
+    - if: $CI_PIPELINE_SOURCE != "merge_request_event" && $CI_PIPELINE_SOURCE != "schedule" && ($CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+/ || $CI_COMMIT_REF_NAME =~ /^r[0-9]+\.[0-9]+/)
       when: always
     - when: never
 
@@ -19,6 +19,6 @@
 .release-nightly-tmp-fix-airshipper:
   stage: build-nightly
   rules:
-    - if: $CI_PIPELINE_SOURCE == "schedule" && ($CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+/ || $CI_COMMIT_REF_NAME =~ /^r[0-9]+\.[0-9]+/)
+    - if: $CI_PIPELINE_SOURCE != "merge_request_event" && $CI_PIPELINE_SOURCE == "schedule" && ($CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+/ || $CI_COMMIT_REF_NAME =~ /^r[0-9]+\.[0-9]+/)
       when: always
     - when: never