From 6f88c070d96009b6a722a72f50caa84bd66b16b6 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Mon, 9 Dec 2024 12:31:56 +0300 Subject: [PATCH] ci: treat all non-protected branches as pull requests --- .gitlab-ci.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6af1abbbe6..112696c7f5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -95,14 +95,16 @@ builder-image: else # CI_EXTERNAL_PULL_REQUEST_IID is false every time until https://gitlab.com/gitlab-org/gitlab/issues/5667 is done # Until then, we're using https://github.com/brndnmtthws/labhub atm to mirror Github pull requests as branches into Gitlab, - # which allows us to use Gitlab CI for Github. The following check detects such mirrored branches. - if [[ $CI_COMMIT_REF_NAME =~ ^pr-[^/]*/[^/]*/[^/]*/[^/]*$ ]]; then + # which allows us to use Gitlab CI for Github. + if [[ $CI_COMMIT_REF_NAME = "master" ]] || [[ $CI_COMMIT_REF_NAME = "develop" ]] || [[ $CI_COMMIT_REF_NAME =~ ^v([0-9]{1,2}\.)*x$ ]]; then + # These names are reserved for protected branches + export PULL_REQUEST="false" + else + # Everything else including experemental "feat/smth" branches must be merged via PRs, treat them as such export PULL_REQUEST="true" # CI_COMMIT_BEFORE_SHA is also invalid until #5667 is implemented, so we need to figure it out by ourself git fetch origin develop export CI_COMMIT_BEFORE_SHA="$(git merge-base origin/develop HEAD)" - else - export PULL_REQUEST="false" fi fi - export COMMIT_RANGE="$CI_COMMIT_BEFORE_SHA..$CI_COMMIT_SHA"