-
-
Notifications
You must be signed in to change notification settings - Fork 45
44 lines (38 loc) · 1.15 KB
/
set_assignees.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
name: Set assignees
on:
pull_request_target:
types:
- opened
jobs:
set-assignees:
name: Set assignees
runs-on: ubuntu-latest
timeout-minutes: 1
steps:
- uses: actions/checkout@v4
- name: Set assignees
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { owner, repo } = context.repo;
const prNumber = context.payload.pull_request.number;
const response = await github.rest.issues.get({
owner,
repo,
issue_number: prNumber,
})
const { assignees } = response.data;
if (assignees.length === 0) {
let assignee = context.actor;
const branchName = context.payload.pull_request.head.ref;
if (branchName.startsWith('dependabot/')) {
assignee = owner;
}
await github.rest.issues.addAssignees({
owner: owner,
repo: repo,
issue_number: prNumber,
assignees: [assignee]
});
}