forked from mui/mui-public
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[infra] Create first reusable workflow (mui#159)
Signed-off-by: Michel Engelen <[email protected]> Co-authored-by: Jose C Quintas Jr <[email protected]>
- Loading branch information
1 parent
fa7ec3a
commit 2e8907e
Showing
3 changed files
with
56 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: Add reviewers to PRs | ||
|
||
on: | ||
pull_request_target: | ||
branches: ['master', 'next'] | ||
types: ['labeled'] | ||
workflow_call: | ||
inputs: | ||
team-slug: | ||
description: 'The slug of the team from which reviewers get collected' | ||
required: true | ||
type: string | ||
label-name: | ||
description: 'The name of the label that triggers the action' | ||
required: true | ||
type: string | ||
secrets: | ||
token: | ||
description: 'The github token to use for the API calls. You can use the GITHUB_TOKEN secret' | ||
required: true | ||
type: string | ||
|
||
permissions: {} | ||
|
||
jobs: | ||
add-reviewers-to-pr: | ||
# Tests that label is added on the PR | ||
if: ${{ github.event.label.name == inputs.label-name }} | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
pull-requests: write | ||
steps: | ||
- id: get-members | ||
run: | | ||
DATA=$(gh api \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
/orgs/${{ github.repository_owner }}/teams/${{ inputs.team-slug }}/members?role=maintainer&per_page=100 \ | ||
| jq 'reduce inputs as $i (.; . += $i)') \ | ||
echo "data=$DATA" >> $GITHUB_OUTPUT | ||
# assign reviewers | ||
- id: assign-reviewers | ||
run: | | ||
curl -L \ | ||
-X POST \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "Authorization: Bearer ${{ secrets.token }}" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
https://api.github.com/repos/${{ github.repository_owner }}/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/requested_reviewers \ | ||
-d '{"reviewers":[${{ join(fromJson(steps.get-members.outputs.data).*.login) }}]}' \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.