-
Notifications
You must be signed in to change notification settings - Fork 16
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] Create first reusable workflow #159
Merged
michelengelen
merged 6 commits into
mui:master
from
michelengelen:automation/create-reusable-workflows
May 6, 2024
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2436d97
cleanup of devlake stuff that is not needed anymore
michelengelen 05307b2
fix typo
michelengelen 8e1c077
adds a reusable workflow to the workflows for assigning reviewers bas…
michelengelen 459b274
changed name to reusable-... to indicate that it is intended to be re…
michelengelen 0e2ea05
changed var name gh-token > token
michelengelen 0419baa
Update .github/workflows/reusable-add-reviewers-to-pr.yml
michelengelen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this logic. Is this PR meant to experiment with reusable workflow?