summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoah Zweben MacBook <noahz@anthropic.com>2026-01-06 19:16:31 -0800
committerNoah Zweben MacBook <noahz@anthropic.com>2026-01-06 19:16:31 -0800
commite5bd3dfed19dd462164962b9d1164087ec438013 (patch)
tree141b8ee5a57d8e5f123e774934ad77745049211d
parent76334d1f676a5f706feb9803c724e693f02771ff (diff)
Use collaborator permission check instead of org membershipfix-external-pr-permission-check
-rw-r--r--.github/workflows/close-external-prs.yml52
1 files changed, 26 insertions, 26 deletions
diff --git a/.github/workflows/close-external-prs.yml b/.github/workflows/close-external-prs.yml
index 61d9544e..0b6e1a8c 100644
--- a/.github/workflows/close-external-prs.yml
+++ b/.github/workflows/close-external-prs.yml
@@ -13,35 +13,35 @@ jobs:
if: vars.DISABLE_EXTERNAL_PR_CHECK != 'true'
runs-on: ubuntu-latest
steps:
- - name: Check if author is org member
+ - name: Check if author has write access
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}`);
- }
+ const { data } = await github.rest.repos.getCollaboratorPermissionLevel({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ username: author
+ });
+
+ if (['admin', 'write'].includes(data.permission)) {
+ console.log(`${author} has ${data.permission} access, allowing PR`);
+ return;
}
+
+ console.log(`${author} has ${data.permission} access, closing PR`);
+
+ 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'
+ });