Skip to content

Commit

Permalink
Merge pull request #11 from GetJobber/avoid-label-removal-fails
Browse files Browse the repository at this point in the history
Avoid failing on label removal errors
  • Loading branch information
thehanimo authored Dec 2, 2021
2 parents 58c2cda + 93a8154 commit 144cc74
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async function run() {
for (let j = 0; j < CHECKS.ignoreLabels.length; j++) {
if (labels[i].name == CHECKS.ignoreLabels[j]) {
core.info(`Ignoring Title Check for label - ${labels[i].name}`);
removeLabel(labels, LABEL.name, true);
removeLabel(labels, LABEL.name);
return;
}
}
Expand All @@ -56,7 +56,7 @@ async function run() {
if (CHECKS.prefixes && CHECKS.prefixes.length) {
for (let i = 0; i < CHECKS.prefixes.length; i++) {
if (title.startsWith(CHECKS.prefixes[i])) {
removeLabel(labels, LABEL.name, CHECKS.alwaysPassCI);
removeLabel(labels, LABEL.name);
core.info(MESSAGES.success);
return;
}
Expand All @@ -66,7 +66,7 @@ async function run() {
if (CHECKS.regexp) {
let re = new RegExp(CHECKS.regexp, CHECKS.regexpFlags || "");
if (re.test(title)) {
removeLabel(labels, LABEL.name, CHECKS.alwaysPassCI);
removeLabel(labels, LABEL.name);
core.info(MESSAGES.success);
return;
}
Expand Down Expand Up @@ -112,7 +112,7 @@ async function addLabel(name) {
core.info(`Added label (${name}) to PR - ${addLabelResponse.status}`);
}

async function removeLabel(labels, name, alwaysPassCI) {
async function removeLabel(labels, name) {
try {
if (
!labels
Expand All @@ -131,12 +131,7 @@ async function removeLabel(labels, name, alwaysPassCI) {
});
core.info(`Removed label - ${removeLabelResponse.status}`);
} catch (error) {
core.info(error);
if (alwaysPassCI) {
core.info(`Failed to remove label (${name}) from PR`);
} else {
core.setFailed(`Failed to remove label (${name}) from PR`);
}
core.info(`Failed to remove label (${name}) from PR: ${error}`);
}
}

Expand Down

0 comments on commit 144cc74

Please sign in to comment.