Skip to content

Commit

Permalink
[infra] Create first reusable workflow (mui#159)
Browse files Browse the repository at this point in the history
Signed-off-by: Michel Engelen <[email protected]>
Co-authored-by: Jose C Quintas Jr <[email protected]>
  • Loading branch information
michelengelen and JCQuintas authored May 6, 2024
1 parent fa7ec3a commit 2e8907e
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 86 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/reusable-add-reviewers-to-pr.yml
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) }}]}' \
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ src
.env.test.local
.env.production.local

# IDE specific files
.idea

npm-debug.log*
yarn-debug.log*
yarn-error.log*
Expand Down Expand Up @@ -53,4 +56,4 @@ packages/toolpad-app/public/typings.json
packages/toolpad-app/prisma/generated


.toolpad-generated
.toolpad-generated
85 changes: 0 additions & 85 deletions tools-public/devlake/docker-compose.yml

This file was deleted.

0 comments on commit 2e8907e

Please sign in to comment.