-
Notifications
You must be signed in to change notification settings - Fork 0
50 lines (45 loc) · 1.86 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
name: Pull Request Review Labeler
on:
pull_request:
types: [opened]
jobs:
check_author_team_membership:
runs-on: ubuntu-latest
steps:
- name: Get opsTrack team members
id: get_opsTrack_members
run: |
team_members=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/orgs/${{ github.event.organization.login }}/teams/opsTrack/members" | \
grep -oP '"login": "\K([^"]+)')
echo "::set-output name=opsTrackMembers::$team_members"
shell: bash
- name: Check if author is opsTrack member
id: check_author
run: |
author_login=$(jq -r '.pull_request.user.login' $GITHUB_EVENT_PATH)
opsTrack_members=$(echo "${{ steps.get_opsTrack_members.outputs.opsTrackMembers }}" | tr '\n' ' ')
is_member=0
for member in $opsTrack_members; do
if [ "$member" == "$author_login" ]; then
is_member=1
break
fi
done
echo "::set-output name=isMember::$is_member"
label_pr_needing_reviews:
needs: check_author_team_membership
runs-on: ubuntu-latest
steps:
- name: Check if opsTrack member
id: opsTrack_member_check
run: echo "Author is opsTrack member:${{ needs.check_author_team_membership.outputs.isMember }}"
- name: Add label if opsTrack member
if: steps.opsTrack_member_check.outputs.isMember == '1'
run: |
echo "Author is a member of opsTrack team, adding label..."
curl -X POST \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.number }}/labels" \
-d '{"labels":["codeowner reviews required"]}'