Skip to content

Commit

Permalink
Continue removing labels with errors (#237)
Browse files Browse the repository at this point in the history
  • Loading branch information
micnncim authored May 23, 2021
1 parent b5db75d commit 335648f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 12 deletions.
22 changes: 16 additions & 6 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -952,13 +952,23 @@ function run() {
return;
}
const client = github.getOctokit(githubToken);
const remaining = [];
for (const label of labels) {
yield client.issues.removeLabel({
name: label,
owner,
repo,
issue_number: number
});
try {
yield client.issues.removeLabel({
name: label,
owner,
repo,
issue_number: number
});
}
catch (e) {
core.warning(`failed to remove label: ${label}: ${e}`);
remaining.push(label);
}
}
if (remaining.length) {
throw new Error(`failed to remove labels: ${remaining}`);
}
}
catch (e) {
Expand Down
22 changes: 16 additions & 6 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,23 @@ async function run(): Promise<void> {

const client = github.getOctokit(githubToken);

const remaining = [];
for (const label of labels) {
await client.issues.removeLabel({
name: label,
owner,
repo,
issue_number: number
});
try {
await client.issues.removeLabel({
name: label,
owner,
repo,
issue_number: number
});
} catch (e) {
core.warning(`failed to remove label: ${label}: ${e}`);
remaining.push(label);
}
}

if (remaining.length) {
throw new Error(`failed to remove labels: ${remaining}`);
}
} catch (e) {
core.error(e);
Expand Down

0 comments on commit 335648f

Please sign in to comment.