-
Notifications
You must be signed in to change notification settings - Fork 311
59 lines (58 loc) · 1.88 KB
/
issue-assignee.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
52
53
54
55
56
57
58
59
name: Auto-add assignees to issues
on:
issues:
types:
- reopened
- opened
jobs:
add_label:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v5
add_assignee:
runs-on: ubuntu-latest
needs: add_label
permissions:
contents: read
issues: write
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set assignees
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
result-encoding: string
retries: 3
retry-exempt-status-codes: 400,401
script: |
let issue_number = context.payload.issue.number;
const labels = (await github.rest.issues.listLabelsOnIssue({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
})).data.map(label => label.name);
const labelToAssignees = {
'product: CLion': ['ujohnny'],
'product: IntelliJ': ['mai93'],
'product: GoLand': ['tpasternak'],
'product: Android Studio': ['mai93'],
'product: PyCharm': ['mai93']
};
const assignees = labels.some(label => label.startsWith('product:'))
? labels.reduce((acc, label) => {
const assignee = label in labelToAssignees ? labelToAssignees[label] : [];
return acc.concat(assignee);
}, [])
: ['sgowroji', 'satyanandak', 'iancha1992'];
if (assignees.length > 0) {
await github.rest.issues.addAssignees({
issue_number,
owner: context.repo.owner,
repo: context.repo.repo,
assignees,
});
}