-
Notifications
You must be signed in to change notification settings - Fork 4
41 lines (36 loc) · 1.37 KB
/
Copy pathpr-assign-author.yml
File metadata and controls
41 lines (36 loc) · 1.37 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
name: pr-assign-author
on:
workflow_call:
jobs:
assign-author:
runs-on: ubuntu-latest
steps:
-
name: Assigning author to PR
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
try {
const dt = context.payload?.pull_request;
if (!dt) {
throw new Error(`No pull request payload found, skipping.`);
}
const { assignees, number, user: { login: author, type } } = dt;
if (assignees.length > 0) {
throw new Error(`Pull request is already assigned to someone, skipping.`);
} else if (type !== 'User') {
throw new Error(`Not a user, skipping.`);
}
const respAdd = await github.rest.issues.addAssignees({
...context.repo,
issue_number: number,
assignees: [author]
});
core.debug(`addAssignees resp: ${JSON.stringify(respAdd, null, 2)}`);
if (respAdd.status !== 201) {
throw new Error(`Failed to assign @${author} to the pull request #${number}.`);
}
core.info(`@${author} has been assigned to the pull request #${number}`);
} catch (e) {
core.warning(e.message);
}