-
Notifications
You must be signed in to change notification settings - Fork 15
49 lines (41 loc) · 1.66 KB
/
close-external-prs.yml
File metadata and controls
49 lines (41 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
name: Close External PRs
on:
pull_request_target:
types: [opened, reopened]
permissions:
pull-requests: write
issues: write
jobs:
close:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v7
with:
script: |
const author = context.payload.pull_request.user.login;
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 the PR! This repo is a **read-only mirror** — its contents are synced nightly from Anthropic's internal review pipeline, so direct pull requests are closed automatically.`,
``,
`To submit a plugin to the community marketplace, use [clau.de/plugin-directory-submission](https://clau.de/plugin-directory-submission).`,
].join('\n'),
});
await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
state: 'closed',
});