Skip to content

Workflow file for this run

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'
});
}