From 4729bbe986a21c189b6136aad2b0cb37489f7f50 Mon Sep 17 00:00:00 2001 From: Michel Engelen <32863416+michelengelen@users.noreply.github.com> Date: Sun, 5 May 2024 00:50:00 +0200 Subject: [PATCH] [infra] Fix automated reviewers assignment workflow - part 2 (#12989) Signed-off-by: Michel Engelen <32863416+michelengelen@users.noreply.github.com> --- .github/workflows/add-release-reviewers.yml | 32 +++++++++------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/.github/workflows/add-release-reviewers.yml b/.github/workflows/add-release-reviewers.yml index 44bc6991e4011..d9c09de4e35f0 100644 --- a/.github/workflows/add-release-reviewers.yml +++ b/.github/workflows/add-release-reviewers.yml @@ -12,6 +12,11 @@ jobs: # Tests that label is added on the PR if: ${{ github.event.label.name == 'release' }} runs-on: ubuntu-latest + env: + ORG: ${{ github.event.organization }} + # we can use the team slug when making this a reusable workflow + TEAM_SLUG: x + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} permissions: contents: read pull-requests: write @@ -21,27 +26,18 @@ jobs: DATA=$(gh api \ -H "Accept: application/vnd.github+json" \ -H "X-GitHub-Api-Version: 2022-11-28" \ - /orgs/${{ORG}}/teams/${{TEAM_SLUG}}/members \ + /orgs/$ORG/teams/$TEAM_SLUG/members?role=maintainer&per_page=100 \ | jq 'reduce inputs as $i (.; . += $i)') \ - | echo "data=$DATA" >> $GITHUB_OUTPUT \ - | echo "members=${{ join(fromJson(DATA).*.login) }}" >> $GITHUB_OUTPUT \ - env: - ORG: ${{ github.event.organization }} - TEAM_SLUG: x - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + echo "data=$DATA" >> $GITHUB_OUTPUT + echo "members=${{ join(fromJson($DATA).*.login) }}" >> $GITHUB_OUTPUT # assign reviewers - id: assign-reviewers run: | curl -L \ - -X POST \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${{GITHUB_TOKEN}}" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - https://api.github.com/repos/${{ORG}}/${{REPO}}/pulls/${{PR_NUMBER}}/requested_reviewers \ - -d '{"reviewers":[${{ steps.get-members.outputs.members }}]}' \ - env: - ORG: ${{ github.event.organization }} - REPO: ${{ github.repository }} - PR_NUMBER: ${{ github.event.pull_request.number }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer $GITHUB_TOKEN" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/$ORG/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/requested_reviewers \ + -d '{"reviewers":[${{ steps.get-members.outputs.members }}]}' \