diff --git a/.github/workflows/triage-label.yml b/.github/workflows/triage-label.yml index b7f6485a31d..0b7251abd83 100644 --- a/.github/workflows/triage-label.yml +++ b/.github/workflows/triage-label.yml @@ -1,11 +1,8 @@ name: Add Triage Label - on: issues: types: opened - permissions: {} - jobs: add_label: runs-on: ubuntu-20.04 @@ -14,7 +11,22 @@ jobs: issues: write steps: - uses: actions/checkout@v3 + # We want to delay the labeling of the issue so that the author has a change to add labels after issue creation. + - name: 'Delay Labeling' + run: sleep 3m + # Make sure that the latest issue is pulled from the database rather than relying on the payload. This is + # because the payload won't include any labels that were added after the issue was created. + - uses: actions/github-script@v6 + id: latest-issue + with: + script: | + const issue = await github.rest.issues.get({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number + }); + core.setOutput('hasLabels', issue.data.labels.length > 0); - uses: actions-ecosystem/action-add-labels@v1 - if: github.event.issue.labels[0] == null + if: ${{ steps.latest-issue.outputs.hasLabels == 'false'}} with: labels: 'status: awaiting triage'