From 1cadee382f8e22dd7c8a99b151600d945d3c3a8e Mon Sep 17 00:00:00 2001 From: Maurus Decimus <11444311+mdecimus@users.noreply.github.com> Date: Wed, 8 Jul 2026 22:59:13 +0200 Subject: [PATCH] Update PR action --- .github/workflows/auto-close-prs.yml | 37 +++++++++++++++++++--------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/.github/workflows/auto-close-prs.yml b/.github/workflows/auto-close-prs.yml index b2cfa344..ce249caf 100644 --- a/.github/workflows/auto-close-prs.yml +++ b/.github/workflows/auto-close-prs.yml @@ -48,18 +48,33 @@ jobs: return; } - try { - const { data: perm } = await github.rest.repos.getCollaboratorPermissionLevel({ - owner: context.repo.owner, - repo: context.repo.repo, - username: author, - }); - if (perm.permission === 'admin' || perm.permission === 'write') { - core.info(`PR #${pr.number} author '${author}' is a collaborator (${perm.permission}). Skipping.`); - return; + const actor = (context.payload.sender && context.payload.sender.login) || ''; + + const isCollaborator = async (username) => { + if (!username) { + return false; } - } catch (err) { - core.info(`Could not resolve collaborator permission for '${author}': ${err.message}`); + try { + const { data: perm } = await github.rest.repos.getCollaboratorPermissionLevel({ + owner: context.repo.owner, + repo: context.repo.repo, + username, + }); + return perm.permission === 'admin' || perm.permission === 'write'; + } catch (err) { + core.info(`Could not resolve collaborator permission for '${username}': ${err.message}`); + return false; + } + }; + + if (await isCollaborator(author)) { + core.info(`PR #${pr.number} author '${author}' is a collaborator. Skipping.`); + return; + } + + if (actor.toLowerCase() !== login && await isCollaborator(actor)) { + core.info(`PR #${pr.number} action triggered by collaborator '${actor}'. Skipping.`); + return; } const contributingUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/blob/HEAD/CONTRIBUTING.md`;