diff --git a/.github/workflows/triage.yml b/.github/workflows/triage.yml new file mode 100644 index 0000000..81f33b8 --- /dev/null +++ b/.github/workflows/triage.yml @@ -0,0 +1,50 @@ +name: Issue Triage + +on: + issues: + types: + - opened + +permissions: + issues: write + +jobs: + add-triage-label: + name: Add triage label + runs-on: ubuntu-latest + steps: + - name: Ensure triage label exists and apply it + uses: actions/github-script@v7 + with: + script: | + const owner = context.repo.owner; + const repo = context.repo.repo; + const issue_number = context.payload.issue.number; + const labelName = 'triage'; + + try { + await github.rest.issues.getLabel({ + owner, + repo, + name: labelName, + }); + } catch (error) { + if (error?.status !== 404) { + throw error; + } + + await github.rest.issues.createLabel({ + owner, + repo, + name: labelName, + color: 'D4C5F9', + description: 'Needs initial triage', + }); + } + + await github.rest.issues.addLabels({ + owner, + repo, + issue_number, + labels: [labelName], + });