From fa50671ee6a0bb5a48d59787f9973da2f955971f Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Mon, 9 Dec 2024 12:14:07 +0300 Subject: [PATCH] ci: only protected branches should have PULL_REQUEST set to false --- .gitlab-ci.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6af1abbbe6382b..effd5a9ec3c0d6 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 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"