Skip to content

Commit 0ab97fe

Browse files
ci: Restrict maintainer check to admin/maintain roles
Everyone at Sentry has write access to this repo, so write-level permission is too broad for the maintainer bypass. Only users with admin or maintain roles should skip the contribution validation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 87149d7 commit 0ab97fe

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

.github/workflows/close-unvetted-pr.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,24 @@ jobs:
2929
const prAuthor = pullRequest.user.login;
3030
const contributingUrl = `https://github.com/${repo.owner}/${repo.repo}/blob/master/CONTRIBUTING.md`;
3131
32-
// --- Helper: check if a user has write+ permission on a repo ---
33-
async function hasWriteAccess(owner, repoName, username) {
32+
// --- Helper: check if a user has admin or maintain permission on a repo ---
33+
async function isMaintainer(owner, repoName, username) {
3434
try {
3535
const { data } = await github.rest.repos.getCollaboratorPermissionLevel({
3636
owner,
3737
repo: repoName,
3838
username,
3939
});
40-
return ['admin', 'maintain', 'write'].includes(data.permission);
40+
return ['admin', 'maintain'].includes(data.permission);
4141
} catch {
4242
return false;
4343
}
4444
}
4545
46-
// --- Step 1: Check if PR author is a maintainer ---
47-
const isMaintainer = await hasWriteAccess(repo.owner, repo.repo, prAuthor);
48-
if (isMaintainer) {
49-
core.info(`PR author ${prAuthor} has write+ access. Skipping.`);
46+
// --- Step 1: Check if PR author is a maintainer (admin or maintain role) ---
47+
const authorIsMaintainer = await isMaintainer(repo.owner, repo.repo, prAuthor);
48+
if (authorIsMaintainer) {
49+
core.info(`PR author ${prAuthor} has admin/maintain access. Skipping.`);
5050
return;
5151
}
5252
core.info(`PR author ${prAuthor} is not a maintainer.`);
@@ -187,7 +187,7 @@ jobs:
187187
188188
for (const user of usersToCheck) {
189189
if (user === prAuthor) continue;
190-
if (await hasWriteAccess(ref.owner, ref.repo, user)) {
190+
if (await isMaintainer(ref.owner, ref.repo, user)) {
191191
maintainerParticipated = true;
192192
core.info(`Maintainer ${user} participated in ${ref.owner}/${ref.repo}#${ref.number}.`);
193193
break;

0 commit comments

Comments
 (0)