-
Notifications
You must be signed in to change notification settings - Fork 3k
Expand file tree
/
Copy pathauto-label-needs-discussion.yml
More file actions
49 lines (44 loc) · 1.66 KB
/
auto-label-needs-discussion.yml
File metadata and controls
49 lines (44 loc) · 1.66 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
42
43
44
45
46
47
48
49
name: 'Auto-apply `needs-discussion` label to externally raised Issues'
on:
issues:
types: [opened]
permissions:
issues: write
jobs:
label-if-external:
runs-on: ubuntu-latest
if: github.repository == 'renovatebot/renovate'
steps:
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
const author = context.payload.issue.user.login;
let roleName;
try {
const { data } = await github.rest.repos.getCollaboratorPermissionLevel({
owner: context.repo.owner,
repo: context.repo.repo,
username: author,
});
roleName = data.role_name;
} catch (err) {
if (err.status === 404) {
// User is not a collaborator — treat as no access
roleName = 'none';
} else {
throw err;
}
}
// allow users who have a minimum of Triage access on the project to raise Issues without auto-labelling
const triagePlus = ['admin', 'maintain', 'write', 'triage'];
if (!triagePlus.includes(roleName)) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.issue.number,
labels: ['needs-discussion'],
});
core.info(`Added 'needs-discussion' label (author role: ${roleName})`);
} else {
core.info(`Skipping label — author has ${roleName} access`);
}