Skip to content

Commit

Permalink
No need to remove label that doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
Cal-L committed Oct 26, 2023
1 parent a1eeb45 commit 3636a1a
Showing 1 changed file with 25 additions and 14 deletions.
39 changes: 25 additions & 14 deletions .github/scripts/apply-e2e-label.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,31 @@ async function main(): Promise<void> {
const octokit: InstanceType<typeof GitHub> = getOctokit(githubToken);

// Remove the label
const removeLabelResponse = await octokit.rest.issues.removeLabel({
owner: owner,
repo: repo,
issue_number: issue_number,
name: e2eLabel,
});

if (removeLabelResponse.status === 200) {
console.log(`Removed (${e2eLabel}) label from PR ${pullRequestLink}`);
} else {
core.setFailed(
`Failed to remove (${e2eLabel}) label from ${pullRequestLink}`,
);
process.exit(1);
try {
const removeLabelResponse = await octokit.rest.issues.removeLabel({
owner: owner,
repo: repo,
issue_number: issue_number,
name: e2eLabel,
});

if (removeLabelResponse.status === 200) {
console.log(`Removed (${e2eLabel}) label from PR ${pullRequestLink}`);
} else {
core.setFailed(
`Failed to remove (${e2eLabel}) label from ${pullRequestLink}`,
);
process.exit(1);
}
} catch (error) {
if (error.message.includes('Label does not exist')) {

Check failure on line 50 in .github/scripts/apply-e2e-label.ts

View workflow job for this annotation

GitHub Actions / apply-e2e-label

Object is of type 'unknown'.
console.log(`(${e2eLabel}) label does not exist on ${pullRequestLink}, no need to remove`)
} else {
core.setFailed(
`An error occured when attempting to remove (${e2eLabel}) label from ${pullRequestLink}: ${error}`,
);
process.exit(1);
}
}

// Reapply the label
Expand Down

0 comments on commit 3636a1a

Please sign in to comment.