Skip to content

Commit 7c4145f

Browse files
authored
Merge pull request #20 from appwrite/EVDOG4LIFE-patch-2
Autoclose Workflow
2 parents 75939ca + caf576b commit 7c4145f

File tree

1 file changed

+3
-55
lines changed

1 file changed

+3
-55
lines changed

.github/workflows/autoclose.yml

+3-55
Original file line numberDiff line numberDiff line change
@@ -3,61 +3,9 @@ name: Auto-close External Pull Requests
33
on:
44
pull_request_target:
55
types: [opened, reopened]
6-
workflow_dispatch:
76

87
jobs:
98
auto_close:
10-
runs-on: ubuntu-latest
11-
steps:
12-
- name: Check if user is organization member
13-
id: check-membership
14-
uses: actions/github-script@v7
15-
with:
16-
github-token: ${{ secrets.GH_AUTO_CLOSE_PR_TOKEN }}
17-
script: |
18-
const org = 'Appwrite';
19-
let isMember = 'non-member';
20-
try {
21-
await github.rest.orgs.checkMembershipForUser({
22-
org: org,
23-
username: context.payload.pull_request.user.login
24-
});
25-
console.log('PR author is a core member. Keeping PR open.');
26-
isMember = 'member';
27-
} catch (error) {
28-
console.log('PR author is not a core member.');
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.');
9+
uses: appwrite/.github/.github/workflows/autoclose.yml@main
10+
secrets:
11+
GH_AUTO_CLOSE_PR_TOKEN: ${{ secrets.GH_AUTO_CLOSE_PR_TOKEN }}

0 commit comments

Comments
 (0)