File tree 1 file changed +11
-17
lines changed
1 file changed +11
-17
lines changed Original file line number Diff line number Diff line change @@ -10,46 +10,40 @@ jobs:
10
10
runs-on : ubuntu-latest
11
11
12
12
steps :
13
- - name : Check if employee
14
- id : check_employee
13
+ - name : Check if user is a member
14
+ id : check_member
15
15
uses : actions/github-script@v6
16
16
with :
17
17
github-token : ${{ secrets.READ_GITHUB_ORG_MEMBERS_TOKEN }}
18
18
result-encoding : string
19
19
script : |
20
20
try {
21
- const response = await github.rest.orgs.checkMembershipForUser({
22
- org: ` github` ,
21
+ const { status } = await github.rest.orgs.checkMembershipForUser({
22
+ org: ' github' ,
23
23
username: context.payload.pull_request.user.login
24
24
});
25
-
26
- if (response.status === 204) {
27
- return true;
28
- } else {
29
- return false;
30
- }
25
+ return status === 204 ? 'true' : 'false';
31
26
} catch (error) {
32
- console.log (error);
27
+ console.error (error);
33
28
return 'false';
34
29
}
35
30
36
31
- name : Close PR
37
- id : close_pr
38
- if : ${{ steps.check_employee.outputs.result == 'false' }}
32
+ if : steps.check_member.outputs.result == 'false'
39
33
uses : actions/github-script@v6
40
34
with :
41
35
github-token : ${{ secrets.GITHUB_TOKEN }}
42
36
script : |
43
- const body = `This pull request is being automatically closed because we do not accept external contributions to this repository.`;
44
-
37
+ const message = `This pull request has been automatically closed because we do not accept external contributions to this repository.`;
38
+
45
39
await github.rest.issues.createComment({
46
40
...context.repo,
47
41
issue_number: context.issue.number,
48
- body: body
42
+ body: message
49
43
});
50
44
51
45
await github.rest.pulls.update({
52
46
...context.repo,
53
47
pull_number: context.payload.pull_request.number,
54
48
state: 'closed'
55
- });
49
+ });
You can’t perform that action at this time.
0 commit comments