-
Notifications
You must be signed in to change notification settings - Fork 21
44 lines (38 loc) · 1.67 KB
/
autoclose.yml
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
name: Auto-close External Pull Requests
on:
pull_request_target:
types: [opened, reopened]
workflow_dispatch:
jobs:
auto_close:
runs-on: ubuntu-latest
steps:
- name: Check if user is organization member and close PR if not
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GH_AUTO_CLOSE_PR_TOKEN }}
script: |
const org = 'Appwrite';
try {
// Core member PR check
await github.rest.orgs.checkMembershipForUser({
org: org,
username: context.payload.pull_request.user.login
});
console.log('PR author is a core member. Keeping PR open.');
return;
} catch (error) {
console.log('PR author is not a core member. Closing PR.');
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
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.'
});
await github.rest.pulls.update({
pull_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
state: 'closed'
});
}