-
Notifications
You must be signed in to change notification settings - Fork 0
49 lines (41 loc) · 1.37 KB
/
author-pr-assignment.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
name: Assign author to PR
on:
pull_request:
types:
- opened
permissions:
issues: write
pull-requests: write
concurrency:
group: ${{github.workflow}}-${{github.ref}}
cancel-in-progress: true
jobs:
assign-author-to-pr:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v7
with:
script: |
const owner = context.repo.owner;
const repo = context.repo.repo;
const issue_number = context.issue.number;
const author = context.payload.pull_request.user.login;
if (author.includes("bot")) {
core.info(`Cannot add bot account (${author}) as assignee`);
return;
}
const assignmentResult = await github.rest.issues.addAssignees({
owner,
repo,
issue_number,
assignees: [author],
});
core.debug(JSON.stringify(assignmentResult));
core.info(`@${author} has been assigned to the pull request: #${context.issue.number}`);
const assigneesResult = await github.rest.issues.listAssignees({
owner,
repo,
issue_number
});
core.debug(JSON.stringify(assigneesResult));
core.info(`Assignees for PR: ${JSON.stringify(assigneesResult.data.map(({login}) => login))}`);