Update PR action

This commit is contained in:
Maurus Decimus
2026-07-08 22:59:13 +02:00
parent 546d801810
commit 1cadee382f

View File

@@ -48,18 +48,33 @@ jobs:
return; return;
} }
const actor = (context.payload.sender && context.payload.sender.login) || '';
const isCollaborator = async (username) => {
if (!username) {
return false;
}
try { try {
const { data: perm } = await github.rest.repos.getCollaboratorPermissionLevel({ const { data: perm } = await github.rest.repos.getCollaboratorPermissionLevel({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
username: author, username,
}); });
if (perm.permission === 'admin' || perm.permission === 'write') { return perm.permission === 'admin' || perm.permission === 'write';
core.info(`PR #${pr.number} author '${author}' is a collaborator (${perm.permission}). Skipping.`); } 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; return;
} }
} catch (err) {
core.info(`Could not resolve collaborator permission for '${author}': ${err.message}`); 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`; const contributingUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/blob/HEAD/CONTRIBUTING.md`;