From 6a02b2336b8a9f7167dcc8533b0c507277715e21 Mon Sep 17 00:00:00 2001 From: Roar Bergheim Date: Thu, 27 Apr 2023 15:49:31 +0200 Subject: [PATCH] Write warning if fail-on-error is false --- index.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index d8237d1b..f062f083 100644 --- a/index.js +++ b/index.js @@ -31,6 +31,13 @@ async function run() { !(core.getInput("fail-on-error").toLowerCase() === "false"), }; + const error = (msg) => { + if (inputs.failOnError) + core.setFailed(msg); + else + core.warning(msg); + }; + const baseBranchRegex = inputs.baseBranchRegex.trim(); const matchBaseBranch = baseBranchRegex.length > 0; @@ -38,7 +45,7 @@ async function run() { const matchHeadBranch = headBranchRegex.length > 0; if (!matchBaseBranch && !matchHeadBranch) { - if (inputs.failOnError) { core.setFailed("No branch regex values have been specified"); } + error("No branch regex values have been specified"); return; } @@ -56,7 +63,7 @@ async function run() { const baseMatches = baseBranch.match(new RegExp(baseBranchRegex)); if (!baseMatches) { - if (inputs.failOnError) { core.setFailed("Base branch name does not match given regex"); } + error("Base branch name does not match given regex"); return; } @@ -75,7 +82,7 @@ async function run() { const headMatches = headBranch.match(new RegExp(headBranchRegex)); if (!headMatches) { - if (inputs.failOnError) { core.setFailed("Head branch name does not match given regex"); } + error("Head branch name does not match given regex"); return; }