Skip to content

Commit 2e8907e

Browse files
[infra] Create first reusable workflow (#159)
Signed-off-by: Michel Engelen <32863416+michelengelen@users.noreply.github.com> Co-authored-by: Jose C Quintas Jr <juniorquintas@gmail.com>
1 parent fa7ec3a commit 2e8907e

File tree

3 files changed

+56
-86
lines changed

3 files changed

+56
-86
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Add reviewers to PRs
2+
3+
on:
4+
pull_request_target:
5+
branches: ['master', 'next']
6+
types: ['labeled']
7+
workflow_call:
8+
inputs:
9+
team-slug:
10+
description: 'The slug of the team from which reviewers get collected'
11+
required: true
12+
type: string
13+
label-name:
14+
description: 'The name of the label that triggers the action'
15+
required: true
16+
type: string
17+
secrets:
18+
token:
19+
description: 'The github token to use for the API calls. You can use the GITHUB_TOKEN secret'
20+
required: true
21+
type: string
22+
23+
permissions: {}
24+
25+
jobs:
26+
add-reviewers-to-pr:
27+
# Tests that label is added on the PR
28+
if: ${{ github.event.label.name == inputs.label-name }}
29+
runs-on: ubuntu-latest
30+
permissions:
31+
contents: read
32+
pull-requests: write
33+
steps:
34+
- id: get-members
35+
run: |
36+
DATA=$(gh api \
37+
-H "Accept: application/vnd.github+json" \
38+
-H "X-GitHub-Api-Version: 2022-11-28" \
39+
/orgs/${{ github.repository_owner }}/teams/${{ inputs.team-slug }}/members?role=maintainer&per_page=100 \
40+
| jq 'reduce inputs as $i (.; . += $i)') \
41+
echo "data=$DATA" >> $GITHUB_OUTPUT
42+
43+
# assign reviewers
44+
- id: assign-reviewers
45+
run: |
46+
curl -L \
47+
-X POST \
48+
-H "Accept: application/vnd.github+json" \
49+
-H "Authorization: Bearer ${{ secrets.token }}" \
50+
-H "X-GitHub-Api-Version: 2022-11-28" \
51+
https://api.github.com/repos/${{ github.repository_owner }}/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/requested_reviewers \
52+
-d '{"reviewers":[${{ join(fromJson(steps.get-members.outputs.data).*.login) }}]}' \

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ src
2222
.env.test.local
2323
.env.production.local
2424

25+
# IDE specific files
26+
.idea
27+
2528
npm-debug.log*
2629
yarn-debug.log*
2730
yarn-error.log*
@@ -53,4 +56,4 @@ packages/toolpad-app/public/typings.json
5356
packages/toolpad-app/prisma/generated
5457

5558

56-
.toolpad-generated
59+
.toolpad-generated

tools-public/devlake/docker-compose.yml

-85
This file was deleted.

0 commit comments

Comments
 (0)