From 67c0d967fdbb19ec48bbdd3f6d4ef39636add18b Mon Sep 17 00:00:00 2001 From: Kenji Miyake Date: Tue, 12 Apr 2022 23:44:00 +0900 Subject: [PATCH] wip: try early exit Signed-off-by: Kenji Miyake --- src/index.js | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/index.js b/src/index.js index 17c9292d4..b53f621a9 100644 --- a/src/index.js +++ b/src/index.js @@ -42,6 +42,19 @@ module.exports = async function run() { pull_number: contextPullRequest.number }); + // Ignore errors if specified labels are added. + if (ignoreLabels) { + const labelNames = pullRequest.labels.map((label) => label.name); + for (const labelName of labelNames) { + if (ignoreLabels.includes(labelName)) { + core.info( + `Validation was skipped because the PR label "${labelName}" was found.` + ); + return; + } + } + } + // Pull requests that start with "[WIP] " are excluded from the check. const isWip = wip && /^\[WIP\]\s/.test(pullRequest.title); @@ -116,20 +129,6 @@ module.exports = async function run() { } } - // Ignore errors if specified labels are added. - if (ignoreLabels && validationError) { - const labelNames = pullRequest.labels.map((label) => label.name); - for (const labelName of labelNames) { - if (ignoreLabels.includes(labelName)) { - core.info( - `Validation was skipped because the PR label "${labelName}" was found.` - ); - validationError = null; - break; - } - } - } - if (wip) { const newStatus = isWip || validationError != null ? 'pending' : 'success';