diff options
| author | Noah Zweben <noahz@anthropic.com> | 2026-01-06 15:06:28 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-01-06 15:06:28 -0800 |
| commit | 6703e9f512c5b5973fe7f67091b4c59b9e4a39d0 (patch) | |
| tree | 3e47d1726caa3733f314ac91d526e0519cfe2db4 /.github/workflows | |
| parent | bf48ae6c75e70c56a0618787ac998ef94d624996 (diff) | |
Add workflow to auto-close external PRs (#140)
* Add workflow to auto-close external PRs
* Update PR comment wording
* Add toggle to disable external PR check
Diffstat (limited to '.github/workflows')
| -rw-r--r-- | .github/workflows/close-external-prs.yml | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/.github/workflows/close-external-prs.yml b/.github/workflows/close-external-prs.yml new file mode 100644 index 00000000..44cacf47 --- /dev/null +++ b/.github/workflows/close-external-prs.yml @@ -0,0 +1,43 @@ +name: Close External PRs + +on: + pull_request_target: + types: [opened] + +jobs: + check-membership: + if: vars.DISABLE_EXTERNAL_PR_CHECK != 'true' + runs-on: ubuntu-latest + steps: + - name: Check if author is org member + uses: actions/github-script@v7 + with: + script: | + const org = 'anthropics'; + const author = context.payload.pull_request.user.login; + + try { + await github.rest.orgs.checkMembershipForUser({ + org: org, + username: author + }); + console.log(`${author} is an org member, allowing PR`); + } catch (e) { + if (e.status === 404) { + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.payload.pull_request.number, + body: `Thanks for your interest! This repo only accepts contributions from Anthropic team members. If you'd like to submit a plugin to the marketplace, please submit your plugin [here](https://docs.google.com/forms/d/e/1FAIpQLSdeFthxvjOXUjxg1i3KrOOkEPDJtn71XC-KjmQlxNP63xYydg/viewform).` + }); + + await github.rest.pulls.update({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.payload.pull_request.number, + state: 'closed' + }); + + console.log(`Closed PR from external contributor: ${author}`); + } + } |
