Skip to content

Update main.yml

Update main.yml #17

Workflow file for this run

name: Pull Request Review Labeler
on:
pull_request:
types: [opened]
jobs:
check_author_team_membership:
runs-on: ubuntu-latest
steps:
- name: Check if author is opsTrack member
id: check_author
run: |
response=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/orgs/${{ github.event.organization.login }}/teams/opsTrack/members")
if [[ $(echo "$response" | grep -c "\"login\": \"${{ github.event.pull_request.user.login }}\"") -gt 0 ]]; then
echo "::set-output name=isMember::true"
else
echo "::set-output name=isMember::false"
fi
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 == 'true'
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"]}'