From 662f8fdc8f25fb16d6972c04ba4eaf780d616286 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Thu, 26 Nov 2026 15:13:37 +0000 Subject: [PATCH] chore: Skip issues of maintainers with a private organization membership --- .github/scripts/issue-triage/triage.js | 30 ++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/.github/scripts/issue-triage/triage.js b/.github/scripts/issue-triage/triage.js index a44a46d50..340b76ccf 100644 --- a/.github/scripts/issue-triage/triage.js +++ b/.github/scripts/issue-triage/triage.js @@ -276,6 +276,32 @@ async function writeSummary(core, heading, lines) { .write(); } +/** + * Whether the author of the issue is the owner, a member or a collaborator of the repo. + * The author association alone is not enough: for the workflow token, a member of an organization + * with a private membership does not show as a member. So the access to the repo is checked too. + */ +async function isMaintainer({ github, core, owner, repo, issue }) { + if (MAINTAINER_ASSOCIATIONS.includes(issue.author_association)) { + core.info(`#${issue.number} was opened by a maintainer (${issue.author_association})`); + return true; + } + + try { + const { data } = await github.rest.repos.getCollaboratorPermissionLevel({ + owner, + repo, + username: issue.user.login, + }); + core.info(`Access of the author: ${data.permission}, association: ${issue.author_association}`); + return data.permission === 'admin' || data.permission === 'write'; + } catch (error) { + if (error.status !== 404) throw error; + core.info(`The author of #${issue.number} has no access to the repo`); + return false; + } +} + /** * Decides what the event asks for: "triage" a new issue, "recheck" a closed one, or null for nothing. * Also returns the bot comment that holds the re-check state. @@ -292,8 +318,8 @@ async function findTask({ github, context, core, owner, repo, issue, includeMain // A manual run is a request of a maintainer, so it also triages issues that are skipped otherwise. if (!manual) { if (issue.user?.type === 'Bot') return skip('was opened by a bot'); - if (!includeMaintainers && MAINTAINER_ASSOCIATIONS.includes(issue.author_association)) { - return skip(`was opened by a maintainer (${issue.author_association})`); + if (!includeMaintainers && (await isMaintainer({ github, core, owner, repo, issue }))) { + return skip('was opened by a maintainer'); } }