Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[infra] Fix automated reviewers assignment workflow #12986

Merged
merged 2 commits into from
May 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 21 additions & 11 deletions .github/workflows/add-release-reviewers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,39 @@ permissions: {}

jobs:
add-reviewers:
if: ${{ github.event.label.name == 'release' }}
# Tests that label is added on the PR
if: ${{ github.event.label.name == 'release' }}
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- id: get-members
uses: garnertb/get-team-members@0482f68c88601800f85145570ea93bf8fcfcf46f
with:
org: mui
team_slug: x
role: maintainer
token: ${{ secrets.GITHUB_TOKEN }}
run: |
DATA=$(gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/orgs/${{ORG}}/teams/${{TEAM_SLUG}}/members \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding this error:
https://github.com/mui/mui-x/actions/runs/8941961408

I guess that you should use $ORG or ${{ env.ORG }} instead of ${{ORG}} 😅

| jq 'reduce inputs as $i (.; . += $i)') \
| echo "data=$DATA" >> $GITHUB_OUTPUT \
| echo "members=${{ join(fromJson(DATA).*.login) }}" >> $GITHUB_OUTPUT \
JCQuintas marked this conversation as resolved.
Show resolved Hide resolved
env:
ORG: ${{ github.event.organization }}
TEAM_SLUG: x
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# assign reviewers
- name: Add reviewer
- id: assign-reviewers
run: |
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "Authorization: Bearer ${{GITHUB_TOKEN}}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/requested_reviewers \
https://api.github.com/repos/${{ORG}}/${{REPO}}/pulls/${{PR_NUMBER}}/requested_reviewers \
-d '{"reviewers":[${{ steps.get-members.outputs.members }}]}' \
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
ORG: ${{ github.event.organization }}
REPO: ${{ github.repository }}
PR_NUMBER: ${{ github.event.pull_request.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading