Skip to content

Commit

Permalink
Write warning if fail-on-error is false
Browse files Browse the repository at this point in the history
  • Loading branch information
rbergheim authored Apr 27, 2023
1 parent 75aa3a3 commit 6a02b23
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,21 @@ 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;

const headBranchRegex = inputs.headBranchRegex.trim();
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;
}

Expand All @@ -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;
}

Expand All @@ -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;
}

Expand Down

0 comments on commit 6a02b23

Please sign in to comment.