-
Notifications
You must be signed in to change notification settings - Fork 622
41 lines (39 loc) · 1.46 KB
/
assign_reviewers.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
name: Assign requested reviewers
# This workflow adds requested reviewers as assignees. If you remove a
# requested reviewer, it will not remove them as an assignee.
#
# See https://github.com/google/blockly/issues/5643 for more
# information on why this was added.
#
# N.B.: Runs with a read-write repo token. Do not check out the
# submitted branch!
on:
pull_request_target:
types: [review_requested]
jobs:
requested-reviewer:
runs-on: ubuntu-latest
steps:
- name: Assign requested reviewer
uses: actions/github-script@v5
with:
script: |
try {
if (context.payload.pull_request === undefined) {
throw new Error("Can't get pull_request payload. " +
'Check a request reviewer event was triggered.');
}
const reviewers = context.payload.pull_request.requested_reviewers;
// Assignees takes in a list of logins rather than the
// reviewer object.
const reviewerNames = reviewers.map(reviewer => reviewer.login);
const {number:issue_number} = context.payload.pull_request;
github.rest.issues.addAssignees({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue_number,
assignees: reviewerNames
});
} catch (error) {
core.setFailed(error.message);
}