Skip to content

Commit

Permalink
Update notify-triagers.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
anshgoyalevil authored Mar 12, 2024
1 parent 1be31fc commit 413a5c9
Showing 1 changed file with 24 additions and 19 deletions.
43 changes: 24 additions & 19 deletions .github/workflows/notify-triagers.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Notify Triagers
name: Notify Triage Maintainers

on:
pull_request_target:
Expand All @@ -17,35 +17,40 @@ jobs:
with:
files: |
**.md
- name: Check PR Changes for non-.md files
id: non-md-pr-changes
uses: tj-actions/changed-files@v42
with:
files: |
!**.md
- name: Read triagers.json
if: steps.md-pr-changes.outputs.any_changed == 'true' || steps.non-md-pr-changes.outputs.any_changed == 'true'
id: read-triagers-json
run: |
mdTriagers=$(jq -r '.mdTriagers[]' triagers.json | tr '\n' ' ')
codeTriagers=$(jq -r '.codeTriagers[]' triagers.json | tr '\n' ' ')
mdTriagers=$(jq -c '.mdTriagers' triagers.json)
codeTriagers=$(jq -c '.codeTriagers' triagers.json)
echo "md-triagers=$mdTriagers" >> $GITHUB_OUTPUT
echo "code-triagers=$codeTriagers" >> $GITHUB_OUTPUT
- name: Add Reviewers
if: steps.md-pr-changes.outputs.any_changed == 'true' || steps.non-md-pr-changes.outputs.any_changed == 'true'
- name: Add reviewers for non-.md files
if: steps.non-md-pr-changes.outputs.any_changed == 'true'
run: |
curl \
-X POST \
-H "Authorization: token ${{ secrets.GH_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/requested_reviewers \
-d '{
"reviewers": ${{ steps.read-triagers-json.outputs.code-triagers }}
}'
- name: Add reviewers for .md files
if: steps.md-pr-changes.outputs.any_changed == 'true'
run: |
reviewers=(${{ steps.read-triagers-json.outputs.code-triagers }} ${{ steps.read-triagers-json.outputs.md-triagers }})
reviewers=$(echo "${reviewers[@]}" | tr ' ' ',')
curl \
-X POST \
-H "Authorization: token ${{ secrets.GH_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/requested_reviewers \
-d '{
"reviewers": ['"${reviewers}"']
}'
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
-X POST \
-H "Authorization: token ${{ secrets.GH_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/requested_reviewers \
-d '{
"reviewers": ${{ steps.read-triagers-json.outputs.md-triagers }}
}'

0 comments on commit 413a5c9

Please sign in to comment.