mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-05-17 21:29:10 +00:00
Drops the `issues: opened` trigger and the issue-closing branch from the gate workflow. PRs from non-collaborators are still auto-closed (scripted contributions are higher-risk than feedback). Issues stay open — agents already gate replies on collaborator status, so external issues simply sit untouched instead of being auto-closed with a stock message.
69 lines
2.2 KiB
YAML
69 lines
2.2 KiB
YAML
name: Gate
|
|
|
|
on:
|
|
pull_request_target:
|
|
types: [opened]
|
|
|
|
permissions:
|
|
issues: write
|
|
pull-requests: write
|
|
|
|
jobs:
|
|
check-membership:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Check org membership and close if external
|
|
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7
|
|
with:
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
script: |
|
|
const sender = context.payload.sender.login;
|
|
const { owner, repo } = context.repo;
|
|
|
|
// Check if user is an org member
|
|
let isMember = false;
|
|
try {
|
|
const { status } = await github.rest.orgs.checkMembershipForUser({
|
|
org: owner,
|
|
username: sender,
|
|
});
|
|
isMember = status === 204 || status === 302;
|
|
} catch (e) {
|
|
isMember = false;
|
|
}
|
|
|
|
if (isMember) {
|
|
console.log(`${sender} is an org member of ${owner}, allowing.`);
|
|
return;
|
|
}
|
|
|
|
// 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 PR.`);
|
|
|
|
await github.rest.pulls.update({
|
|
...context.repo,
|
|
pull_number: context.payload.pull_request.number,
|
|
state: 'closed',
|
|
});
|
|
await github.rest.issues.createComment({
|
|
...context.repo,
|
|
issue_number: context.payload.pull_request.number,
|
|
body: 'This repository only accepts pull requests from organization members and collaborators. Your PR has been closed automatically.',
|
|
});
|