Skip to content

Update main.yml

Update main.yml #14

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: 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 }}"

Check failure on line 40 in .github/workflows/main.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/main.yml

Invalid workflow file

You have an error in your yaml syntax on line 40
- 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"]}'