File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Contributor Label
2+
3+ on :
4+ pull_request_target :
5+ types : [opened, reopened]
6+
7+ permissions :
8+ issues : write
9+ pull-requests : read
10+
11+ jobs :
12+ label :
13+ name : Add contributor label
14+ runs-on : ubuntu-latest
15+ steps :
16+ - uses : actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
17+ with :
18+ github-token : ${{ secrets.GITHUB_TOKEN }}
19+ script : |
20+ const owner = context.repo.owner;
21+ const repo = context.repo.repo;
22+
23+ let permission = 'none';
24+
25+ try {
26+ const { data } = await github.rest.repos.getCollaboratorPermissionLevel({
27+ owner,
28+ repo,
29+ username: context.payload.pull_request.user.login,
30+ });
31+
32+ permission = data.permission;
33+ } catch (error) {
34+ if (error.status !== 404) {
35+ throw error;
36+ }
37+ }
38+
39+ if (
40+ !['MEMBER', 'OWNER'].includes(context.payload.pull_request.author_association) &&
41+ !['admin', 'maintain', 'write'].includes(permission)
42+ ) {
43+ return;
44+ }
45+
46+ await github.rest.issues.addLabels({
47+ owner,
48+ repo,
49+ issue_number: context.issue.number,
50+ labels: ['Contributor: Internal'],
51+ });
You can’t perform that action at this time.
0 commit comments