|
9 | 9 | auto_close:
|
10 | 10 | runs-on: ubuntu-latest
|
11 | 11 | steps:
|
12 |
| - - name: Check if user is organization member and close PR if not |
| 12 | + - name: Check if user is organization member |
| 13 | + id: check-membership |
13 | 14 | uses: actions/github-script@v7
|
14 | 15 | with:
|
15 | 16 | github-token: ${{ secrets.GH_AUTO_CLOSE_PR_TOKEN }}
|
16 | 17 | script: |
|
17 | 18 | const org = 'Appwrite';
|
18 |
| -
|
| 19 | + let isMember = 'non-member'; |
19 | 20 | try {
|
20 |
| - // Core member PR check |
21 | 21 | await github.rest.orgs.checkMembershipForUser({
|
22 | 22 | org: org,
|
23 | 23 | username: context.payload.pull_request.user.login
|
24 | 24 | });
|
25 |
| - |
26 | 25 | console.log('PR author is a core member. Keeping PR open.');
|
27 |
| - return; |
| 26 | + isMember = 'member'; |
28 | 27 | } catch (error) {
|
29 |
| - console.log('PR author is not a core member. Closing PR.'); |
30 |
| - |
31 |
| - await github.rest.issues.createComment({ |
32 |
| - issue_number: context.issue.number, |
33 |
| - owner: context.repo.owner, |
34 |
| - repo: context.repo.repo, |
35 |
| - body: 'This library is auto-generated by the Appwrite [SDK Generator](https://github.com/appwrite/sdk-generator), and does not accept pull requests directly. To learn more about how you can help us improve this SDK, please check the [contributing guide](https://github.com/appwrite/sdk-generator/blob/master/CONTRIBUTING.md) before submitting a pull request.' |
36 |
| - }); |
37 |
| -
|
38 |
| - await github.rest.pulls.update({ |
39 |
| - pull_number: context.issue.number, |
40 |
| - owner: context.repo.owner, |
41 |
| - repo: context.repo.repo, |
42 |
| - state: 'closed' |
43 |
| - }); |
| 28 | + console.log('PR author is not a core member.'); |
44 | 29 | }
|
| 30 | + return isMember; |
| 31 | + result-encoding: string |
| 32 | + |
| 33 | + - name: Set member output |
| 34 | + id: set-output |
| 35 | + run: echo "result=${{ steps.check-membership.outputs.result }}" >> $GITHUB_ENV |
| 36 | + |
| 37 | + - name: Comment on PR |
| 38 | + if: env.result == 'non-member' |
| 39 | + uses: actions/github-script@v7 |
| 40 | + with: |
| 41 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 42 | + script: | |
| 43 | + await github.rest.issues.createComment({ |
| 44 | + issue_number: context.issue.number, |
| 45 | + owner: context.repo.owner, |
| 46 | + repo: context.repo.repo, |
| 47 | + body: 'This library is auto-generated by the Appwrite [SDK Generator](https://github.com/appwrite/sdk-generator), and does not accept pull requests directly. To learn more about how you can help us improve this SDK, please check the [contributing guide](https://github.com/appwrite/sdk-generator/blob/master/CONTRIBUTING.md) before submitting a pull request.' |
| 48 | + }); |
| 49 | + console.log('Comment added to PR.'); |
| 50 | +
|
| 51 | + - name: Close PR |
| 52 | + if: env.result == 'non-member' |
| 53 | + uses: actions/github-script@v7 |
| 54 | + with: |
| 55 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 56 | + script: | |
| 57 | + await github.rest.pulls.update({ |
| 58 | + pull_number: context.issue.number, |
| 59 | + owner: context.repo.owner, |
| 60 | + repo: context.repo.repo, |
| 61 | + state: 'closed' |
| 62 | + }); |
| 63 | + console.log('PR closed.'); |
0 commit comments