Skip to content

Commit

Permalink
don't add label if it already exists
Browse files Browse the repository at this point in the history
  • Loading branch information
victorhuangwq committed May 16, 2024
1 parent 514b35a commit 70e493d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/tagPriorityLow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,26 @@ jobs:

// Add priority-low label to GitHub issues
const addLowPriorityLabel = async (issueNumber) => {
// Check if the issue already has the label
const { data: labels } = await github.rest.issues.listLabelsOnIssue({
issue_number: issueNumber,
owner: context.repo.owner,
repo: context.repo.repo
});

if (labels.some(l => l.name === 'priority-low')) {
console.log(`Issue #${issueNumber} already has the label`);
return;
}

// Add the label
await github.rest.issues.addLabels({
issue_number: issueNumber,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['priority-low']
});
console.log(`Added label to issue #${issueNumber}`);
}

ghIssueNumbers.forEach(async (issueNumber) => {
Expand Down

0 comments on commit 70e493d

Please sign in to comment.