mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-04-29 20:39:29 +00:00
fix: allow repo collaborators through the gate workflow (#1166)
Previously only org members were allowed. Now checks both org membership and repo collaborator status, so invited collaborators can open issues and PRs without being blocked. Co-authored-by: lab <6723574+louisgv@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
2d8c4a4734
commit
a4fe0388c1
1 changed files with 24 additions and 7 deletions
31
.github/workflows/gate.yml
vendored
31
.github/workflows/gate.yml
vendored
|
|
@ -20,27 +20,44 @@ jobs:
|
|||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
const sender = context.payload.sender.login;
|
||||
const org = context.repo.owner;
|
||||
const { owner, repo } = context.repo;
|
||||
|
||||
// Check if user is an org member
|
||||
let isMember = false;
|
||||
try {
|
||||
const { status } = await github.rest.orgs.checkMembershipForUser({
|
||||
org,
|
||||
org: owner,
|
||||
username: sender,
|
||||
});
|
||||
isMember = status === 204 || status === 302;
|
||||
} catch (e) {
|
||||
// 404 = not a member, anything else = treat as non-member
|
||||
isMember = false;
|
||||
}
|
||||
|
||||
if (isMember) {
|
||||
console.log(`${sender} is a member of ${org}, allowing.`);
|
||||
console.log(`${sender} is an org member of ${owner}, allowing.`);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`${sender} is NOT a member of ${org}, closing.`);
|
||||
// Check if user is a repo collaborator
|
||||
let isCollaborator = false;
|
||||
try {
|
||||
const { status } = await github.rest.repos.checkCollaborator({
|
||||
owner,
|
||||
repo,
|
||||
username: sender,
|
||||
});
|
||||
isCollaborator = status === 204;
|
||||
} catch (e) {
|
||||
isCollaborator = false;
|
||||
}
|
||||
|
||||
if (isCollaborator) {
|
||||
console.log(`${sender} is a collaborator on ${owner}/${repo}, allowing.`);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`${sender} is NOT a member or collaborator, closing.`);
|
||||
|
||||
if (context.payload.issue) {
|
||||
await github.rest.issues.update({
|
||||
|
|
@ -51,7 +68,7 @@ jobs:
|
|||
await github.rest.issues.createComment({
|
||||
...context.repo,
|
||||
issue_number: context.payload.issue.number,
|
||||
body: 'This repository only accepts issues from organization members. Your issue has been closed automatically.',
|
||||
body: 'This repository only accepts issues from organization members and collaborators. Your issue has been closed automatically.',
|
||||
});
|
||||
} else if (context.payload.pull_request) {
|
||||
await github.rest.pulls.update({
|
||||
|
|
@ -62,6 +79,6 @@ jobs:
|
|||
await github.rest.issues.createComment({
|
||||
...context.repo,
|
||||
issue_number: context.payload.pull_request.number,
|
||||
body: 'This repository only accepts pull requests from organization members. Your PR has been closed automatically.',
|
||||
body: 'This repository only accepts pull requests from organization members and collaborators. Your PR has been closed automatically.',
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue