From fc7eeab3533827d2e185226f2078ac79287a7270 Mon Sep 17 00:00:00 2001 From: Gordon Shotwell Date: Fri, 28 Jul 2023 11:56:24 -0300 Subject: [PATCH 1/3] Add a triage label to issues created by non-maintainers --- .github/workflows/triage-issues.yaml | 29 ++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/triage-issues.yaml diff --git a/.github/workflows/triage-issues.yaml b/.github/workflows/triage-issues.yaml new file mode 100644 index 000000000..5e51e20aa --- /dev/null +++ b/.github/workflows/triage-issues.yaml @@ -0,0 +1,29 @@ +name: Issue Management + +on: + issues: + types: [opened] + +jobs: + triage_or_add_to_project: + runs-on: ubuntu-latest + + steps: + - name: Check if the issue creator is a maintainer + id: check_maintainer + run: | + echo "::set-output name=is_maintainer::$(curl -s -H 'Authorization: token ${{ secrets.GITHUB_TOKEN }}' \ + https://api.github.com/repos/${{ github.repository }}/collaborators/${{ github.event.issue.user.login }}/permission \ + | jq -r '.permission' | grep -q 'admin' && echo 'true' || echo 'false')" + + - name: Apply "needs triage" label to issues created by non-maintainers + if: steps.check_maintainer.outputs.is_maintainer == 'false' + uses: actions/github-script@v6 + with: + script: | + github.rest.issues.addLabels({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + labels: ["needs-triage"] + }) From ca909662a26a756776308470b60e6e41a13c3db2 Mon Sep 17 00:00:00 2001 From: Gordon Shotwell Date: Fri, 4 Aug 2023 10:48:59 -0300 Subject: [PATCH 2/3] Update .github/workflows/triage-issues.yaml Co-authored-by: Barret Schloerke --- .github/workflows/triage-issues.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/triage-issues.yaml b/.github/workflows/triage-issues.yaml index 5e51e20aa..d9c700018 100644 --- a/.github/workflows/triage-issues.yaml +++ b/.github/workflows/triage-issues.yaml @@ -12,9 +12,8 @@ jobs: - name: Check if the issue creator is a maintainer id: check_maintainer run: | - echo "::set-output name=is_maintainer::$(curl -s -H 'Authorization: token ${{ secrets.GITHUB_TOKEN }}' \ - https://api.github.com/repos/${{ github.repository }}/collaborators/${{ github.event.issue.user.login }}/permission \ - | jq -r '.permission' | grep -q 'admin' && echo 'true' || echo 'false')" + IS_ADMIN=`gh api /repos/rstudio/py-shiny/collaborators/${{ github.event.issue.user.login }}/permission --jq='.user.permissions.admin'` + echo "is_maintainer=$IS_ADMIN" >> "$GITHUB_OUTPUT" - name: Apply "needs triage" label to issues created by non-maintainers if: steps.check_maintainer.outputs.is_maintainer == 'false' From c0d8404d871c06ebcc52c1345e51388325db82ee Mon Sep 17 00:00:00 2001 From: Gordon Shotwell Date: Fri, 4 Aug 2023 10:51:42 -0300 Subject: [PATCH 3/3] Apply suggestions from code review Barret's changes Co-authored-by: Barret Schloerke --- .github/workflows/triage-issues.yaml | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/.github/workflows/triage-issues.yaml b/.github/workflows/triage-issues.yaml index d9c700018..c34998e60 100644 --- a/.github/workflows/triage-issues.yaml +++ b/.github/workflows/triage-issues.yaml @@ -7,6 +7,9 @@ on: jobs: triage_or_add_to_project: runs-on: ubuntu-latest + + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - name: Check if the issue creator is a maintainer @@ -17,12 +20,5 @@ jobs: - name: Apply "needs triage" label to issues created by non-maintainers if: steps.check_maintainer.outputs.is_maintainer == 'false' - uses: actions/github-script@v6 - with: - script: | - github.rest.issues.addLabels({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - labels: ["needs-triage"] - }) + run: | + gh issue edit ${{ github.event.number }} --add-label "needs-triage" --repo ${{ github.repository }}