From 87a16d49b786438fee8b7eba344630b9b2bc47f7 Mon Sep 17 00:00:00 2001 From: k8s-infra-cherrypick-robot <90416843+k8s-infra-cherrypick-robot@users.noreply.github.com> Date: Thu, 25 Jul 2024 18:33:42 -0700 Subject: [PATCH] CI require a 'lgtm' or 'ok-to-test' labels to pass (#11390) - Require a 'lgtm' or 'ok-to-test' label for running CI after the moderator stage Signed-off-by: ant31 <2t.antoine@gmail.com> Co-authored-by: ant31 <2t.antoine@gmail.com> --- .gitlab-ci.yml | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cc04aa98e..0560e9652 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,8 +2,8 @@ stages: - build - unit-tests - - deploy-part1 - moderator + - deploy-part1 - deploy-part2 - deploy-part3 - deploy-special @@ -65,14 +65,30 @@ before_script: # For failfast, at least 1 job must be defined in .gitlab-ci.yml # Premoderated with manual actions -ci-authorized: - extends: .job +ci-not-authorized: stage: moderator + before_script: [] + after_script: [] + rules: + # LGTM or ok-to-test labels + - if: $PR_LABELS =~ /.*,(lgtm|ok-to-test).*|^(lgtm|ok-to-test).*/i + variables: + CI_OK_TO_TEST: '0' + when: always + - if: $CI_PIPELINE_SOURCE == "schedule" || $CI_PIPELINE_SOURCE == "trigger" + variables: + CI_OK_TO_TEST: '0' + - if: $CI_COMMIT_BRANCH == "master" + variables: + CI_OK_TO_TEST: '0' + - when: always + variables: + CI_OK_TO_TEST: '1' script: - - /bin/sh scripts/premoderator.sh - except: ['triggers', 'master'] - # Disable ci moderator - only: [] + - exit $CI_OK_TO_TEST + tags: + - light + include: - .gitlab-ci/build.yml