From 51a002bd471893ddbaff950f9a0e4b68e4af35d1 Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Sat, 2 Sep 2023 15:24:07 +0200 Subject: [PATCH] [core] Ensure at least one label exists on issues --- .github/workflows/ensure-triage-label.yml | 35 +++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/ensure-triage-label.yml diff --git a/.github/workflows/ensure-triage-label.yml b/.github/workflows/ensure-triage-label.yml new file mode 100644 index 0000000..c4753cc --- /dev/null +++ b/.github/workflows/ensure-triage-label.yml @@ -0,0 +1,35 @@ +name: Ensure triage label is present + +on: + label: + types: + - deleted + issues: + types: + - opened + +permissions: {} + +jobs: + label_issues: + runs-on: ubuntu-latest + permissions: + issues: write + steps: + - uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6 + with: + script: | + const { data: labels } = await github.rest.issues.listLabelsOnIssue({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + }); + + if (labels.length <= 0) { + await github.rest.issues.addLabels({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + labels: ['status: needs triage'] + }) + }