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