-
Notifications
You must be signed in to change notification settings - Fork 15
51 lines (43 loc) · 1.47 KB
/
request-docs-review.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
51
name: 'Add docs reviewers'
on:
# Needs to be pull_request_target for pull-request write permission
pull_request_target:
paths:
- '**/docs/**/*.md'
types:
- opened
- synchronize
- reopened
- ready_for_review
jobs:
add-docs-reviewers:
if: github.event.pull_request.draft == false
permissions:
pull-requests: write
runs-on: ubuntu-22.04
steps:
- name: Add docs reviewers
uses: actions/github-script@v7
with:
script: |
const reviewer = 'margaretkennedy';
const pendingReviewers = await github.rest.pulls.listRequestedReviewers({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
});
const isPending = pendingReviewers.data?.users?.some(({ login }) => login === reviewer);
const reviews = await github.rest.pulls.listReviews({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
});
const isReviewed = reviews.data?.some(review => review.user.login === reviewer);
if (!isPending && !isReviewed) {
github.rest.pulls.requestReviewers({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
reviewers: [reviewer]
});
}