From 606f5336d680037c430fc6fbc4b1744e04075c4e Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Mon, 23 Sep 2024 11:06:04 +0200 Subject: [PATCH] fix: allow skip-check label on PRs to main --- src/index.ts | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/index.ts b/src/index.ts index 916ba2a..a317ad0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -215,6 +215,19 @@ const probotHandler: ApplicationFunction = async (robot, { getRouter }) => { checkRun = response.data; } + // Allow the PR to skip backport label checking if it has the SKIP_CHECK_LABEL. + if (await labelExistsOnPR(context, pr.number, SKIP_CHECK_LABEL)) { + robot.log( + `#${pr.number} is labeled with ${SKIP_CHECK_LABEL} - skipping backport validation check`, + ); + await updateBackportValidityCheck(context, checkRun, { + title: 'Backport Check Skipped', + summary: 'This PR is not a backport - skip backport validation check', + conclusion: CheckRunStatus.NEUTRAL, + }); + return; + } + if (pr.base.ref !== pr.base.repo.default_branch) { // Ensure that we aren't including our own base branch in the backport process. if (action === 'labeled') { @@ -232,21 +245,6 @@ const probotHandler: ApplicationFunction = async (robot, { getRouter }) => { } } - // If a branch is targeting something that isn't main it might not be a backport; - // allow for a label to skip backport validity check for these branches. - if (await labelExistsOnPR(context, pr.number, SKIP_CHECK_LABEL)) { - robot.log( - `#${pr.number} is labeled with ${SKIP_CHECK_LABEL} - skipping backport validation check`, - ); - await updateBackportValidityCheck(context, checkRun, { - title: 'Backport Check Skipped', - summary: - 'This PR is not a backport - skip backport validation check', - conclusion: CheckRunStatus.NEUTRAL, - }); - return; - } - const FASTTRACK_PREFIXES = ['build:', 'ci:']; const FASTTRACK_USERS = [ getEnvVar('BOT_USER_NAME'),