From 12c033bce32236abc17af19eebc39d0f99d9d086 Mon Sep 17 00:00:00 2001 From: Victor Huang Date: Thu, 23 May 2024 14:21:07 -0700 Subject: [PATCH] don't add label if it already exists --- .github/workflows/tagPriorityLow.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/tagPriorityLow.yml b/.github/workflows/tagPriorityLow.yml index 6ce1c7f21..0d79cf92a 100644 --- a/.github/workflows/tagPriorityLow.yml +++ b/.github/workflows/tagPriorityLow.yml @@ -81,12 +81,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) => {