fix: allow Forgejo bot actor on non-comment events

The self-trigger guard blocked the claude bot on all events. Loop risk
only exists for comment/review events (tag mode). PR, workflow_dispatch,
and schedule events are safe — refined the guard to only block on
issue_comment, issues, pull_request_review, and
pull_request_review_comment events.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Vlad MocanuandClaude Opus 4.6 committed 2026-02-27 13:57:59 +02:00
1 parent 307af41a7f
commit c97c9765c3
2 files changed
+58 -5

No files matched your search

+22 -5
View File
@@ -18,14 +18,31 @@ export async function checkHumanActor(
// check but still guard against self-triggering (infinite loop prevention).
if (detectPlatform() === "forgejo") {
const botName = githubContext.inputs.botName.replace(/\[bot\]$/, "");
if (
const isBotActor =
githubContext.actor === botName ||
githubContext.actor === githubContext.inputs.botName
) {
throw new Error(
`Blocking self-trigger on Forgejo: actor '${githubContext.actor}' matches bot_name '${githubContext.inputs.botName}'. This prevents infinite loops.`,
githubContext.actor === githubContext.inputs.botName;
if (isBotActor) {
// Self-trigger loop risk only exists for comment/issue events (tag mode).
// PR and other events (agent mode, workflow_dispatch) are safe — the bot
// pushing a branch or being triggered by schedule can't cause loops.
const loopRiskEvents = [
"issue_comment",
"issues",
"pull_request_review_comment",
"pull_request_review",
];
if (loopRiskEvents.includes(githubContext.eventName)) {
throw new Error(
`Blocking self-trigger on Forgejo: actor '${githubContext.actor}' matches bot_name '${githubContext.inputs.botName}'. This prevents infinite loops.`,
);
}
console.log(
`Forgejo bot actor '${githubContext.actor}' allowed for event '${githubContext.eventName}' (no loop risk)`,
);
return;
}
console.log(
`Forgejo actor check passed for: ${githubContext.actor} (bot_name: ${githubContext.inputs.botName})`,
);