-
Notifications
You must be signed in to change notification settings - Fork 1.1k
73 lines (65 loc) · 2.18 KB
/
labeler.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
name: Labeler
on:
issues:
types: [opened]
pull_request_target:
types: [opened]
jobs:
label-priority:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- name: Label New Issue or PR
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
let label = '';
let username = '';
let issueOrPrNumber = 0;
if (context.eventName === 'issues') {
username = context.payload.issue.user.login;
issueOrPrNumber = context.payload.issue.number;
} else if (context.eventName === 'pull_request_target') {
username = context.payload.pull_request.user.login;
issueOrPrNumber = context.payload.pull_request.number;
}
// Check if an Adafruit member
try {
const adafruitResponse = await github.rest.orgs.checkMembershipForUser({
org: 'adafruit',
username: username
});
if (adafruitResponse.status === 204) {
console.log('Adafruit Member');
label = 'Prio Urgent';
}
} catch (error) {
console.log('Not an Adafruit member');
}
// Check if a contributor
if (label == '') {
try {
const collaboratorResponse = await github.rest.repos.checkCollaborator({
owner: context.repo.owner,
repo: context.repo.repo,
username: username
});
if (collaboratorResponse.status === 204) {
console.log('Contributor');
label = 'Prio Higher';
}
} catch (error) {
console.log('Not a contributor');
}
}
if (label !== '') {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueOrPrNumber,
labels: [label]
});
}