-
Notifications
You must be signed in to change notification settings - Fork 0
27 lines (25 loc) · 1.14 KB
/
Copy pathrequest-review.yml
File metadata and controls
27 lines (25 loc) · 1.14 KB
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
name: PR - Request Reviewer
on:
pull_request:
types: [opened,reopened,ready_for_review]
jobs:
add-reviewer:
runs-on: ubuntu-latest
if: vars.PR_DEFAULT_REVIEWER != '' && !github.event.pull_request.draft
steps:
- name: Check for reviewers
id: check
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
requested=$(gh pr view -R '${{github.repository}}' ${{ github.event.pull_request.number }} --json reviewRequests --jq '.reviewRequests | length')
completed=$(gh pr view -R '${{github.repository}}' ${{ github.event.pull_request.number }} --json reviews --jq '.reviews | length')
total=$((requested + completed))
echo "total_reviews=$total" >> $GITHUB_OUTPUT
- name: Request review
if: steps.check.outputs.total_reviews == '0' && vars.PR_DEFAULT_REVIEWER != github.event.pull_request.user.login
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_DEFAULT_REVIEWER: ${{ vars.PR_DEFAULT_REVIEWER }}
run: |
gh pr edit -R '${{github.repository}}' ${{ github.event.pull_request.number }} --add-reviewer "$PR_DEFAULT_REVIEWER"