-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
51 lines (43 loc) · 1.34 KB
/
Copy pathcontributor-label.yml
File metadata and controls
51 lines (43 loc) · 1.34 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
50
51
name: Contributor Label
on:
pull_request_target:
types: [opened, reopened]
permissions:
issues: write
pull-requests: write
jobs:
label:
name: Add contributor label
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const owner = context.repo.owner;
const repo = context.repo.repo;
let permission = 'none';
try {
const { data } = await github.rest.repos.getCollaboratorPermissionLevel({
owner,
repo,
username: context.payload.pull_request.user.login,
});
permission = data.permission;
} catch (error) {
if (error.status !== 404) {
throw error;
}
}
if (
!['MEMBER', 'OWNER'].includes(context.payload.pull_request.author_association) &&
!['admin', 'maintain', 'write'].includes(permission)
) {
return;
}
await github.rest.issues.addLabels({
owner,
repo,
issue_number: context.issue.number,
labels: ['Contributor: Internal'],
});