Skip to content

Commit

Permalink
Merge pull request #1601 from hackforla/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
sydneywalcoff authored Oct 8, 2024
2 parents d8916aa + 0211875 commit 6db2668
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions .github/workflows/scripts/weekly-label-check.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ async function fetchOpenIssues() {

async function main() {
const openIssues = await fetchOpenIssues();
let totalSuccessfulIssues = 0;

for (const issue of openIssues) {
const labels = issue.labels.map((label) => label.name);
Expand All @@ -48,9 +49,17 @@ async function main() {
);
} else {
console.log(`Labels to add for issue #${issue.number}: `, labelsToAdd);
await addLabels(labelsToAdd, issue.number);
const successfulIssue = await addLabels(labelsToAdd, issue.number);

if (successfulIssue) {
totalSuccessfulIssues++;
console.log(`Successfully added labels to issue #${issue.number}`);
} else {
throw new Error(`Failed to process issue #${issue.number}`);
}
}
}
console.log(totalSuccessfulIssues, " issues have been successfully labeled");
}

function filterLabels(labels) {
Expand Down Expand Up @@ -88,14 +97,20 @@ async function addLabels(
issue_number: issueNum,
labels: labels,
});
if (labelsToAdd.length > 0) {
console.log("Successfully added labels to issue #", issueNum);
}
return true;
} catch (err) {
console.error("Error editing labels: ", err);
return false;
throw new Error(
`Failed to add labels to issue #${issueNum}: ${err.message}`
);
}
}

main().catch(console.error);
(async () => {
try {
await main();
} catch (err) {
console.error("Action aborted because error occurred:", err.message);
process.exit(1);
}
})();

0 comments on commit 6db2668

Please sign in to comment.