From 35d06bc8bb2bd23754a6b2cce832e7b5a35479fa Mon Sep 17 00:00:00 2001 From: Emily Zhao Date: Fri, 27 Sep 2024 10:11:09 -0700 Subject: [PATCH] Update triagelabel.yml --- .github/workflows/triagelabel.yml | 35 ++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/.github/workflows/triagelabel.yml b/.github/workflows/triagelabel.yml index 75456f56..74127b0c 100644 --- a/.github/workflows/triagelabel.yml +++ b/.github/workflows/triagelabel.yml @@ -1,17 +1,28 @@ -name: Label issues +name: Add Triage Label + on: issues: - types: - - reopened - - opened + types: [opened] + jobs: - label_issues: + triage: runs-on: ubuntu-latest - permissions: - issues: write steps: - - run: gh issue edit "$NUMBER" --add-label "triage" - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GH_REPO: ${{ github.repository }} - NUMBER: ${{ github.event.issue.number }} + - name: Check for existing labels + id: check_labels + uses: actions/github-script@v6 + with: + script: | + const labels = await github.issues.listLabelsOnIssue({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number + }); + return labels.data.length > 0; + + - name: Add Triage Label + if: steps.check_labels.outputs.result == 'false' + uses: actions-ecosystem/action-add-labels@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + labels: triage