diff --git a/src/github/context.ts b/src/github/context.ts index 07b0df0..4ea84f9 100644 --- a/src/github/context.ts +++ b/src/github/context.ts @@ -68,10 +68,23 @@ const FORGEJO_EVENT_NAME_MAP: Record = { pull_request_comment: "pull_request_review_comment", }; +/** + * Forgejo uses different action names for some webhook event actions. + * Normalize to GitHub-canonical names so all downstream code works unchanged. + */ +const FORGEJO_EVENT_ACTION_MAP: Record = { + label_updated: "labeled", +}; + function normalizeEventName(eventName: string): string { return FORGEJO_EVENT_NAME_MAP[eventName] ?? eventName; } +function normalizeEventAction(action: string | undefined): string | undefined { + if (!action) return action; + return FORGEJO_EVENT_ACTION_MAP[action] ?? action; +} + const AUTOMATION_EVENT_NAMES = [ "workflow_dispatch", "repository_dispatch", @@ -149,7 +162,7 @@ export function parseGitHubContext(): GitHubContext { const commonFields = { runId: process.env.GITHUB_RUN_ID!, - eventAction: context.payload.action, + eventAction: normalizeEventAction(context.payload.action), repository: { owner: context.repo.owner, repo: context.repo.repo, diff --git a/src/github/validation/trigger.ts b/src/github/validation/trigger.ts index f8b3685..c16cdf1 100644 --- a/src/github/validation/trigger.ts +++ b/src/github/validation/trigger.ts @@ -36,12 +36,7 @@ export function checkContainsTrigger(context: ParsedGitHubContext): boolean { } // Check for label trigger - // Forgejo sends "label_updated" instead of "labeled" for issue label events - if ( - isIssuesEvent(context) && - (context.eventAction === "labeled" || - context.eventAction === "label_updated") - ) { + if (isIssuesEvent(context) && context.eventAction === "labeled") { const labelName = (context.payload as any).label?.name || ""; if (labelTrigger && labelName === labelTrigger) {