fix: normalize Forgejo 'label_updated' to 'labeled' in context
Forgejo sends eventAction 'label_updated' instead of 'labeled' for issue label events. Add FORGEJO_EVENT_ACTION_MAP in context.ts to normalize at parse time (same pattern as event name normalization), so all downstream code (trigger.ts, create-prompt) works unchanged. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
fa0070ddcc
commit
baa007a3ec
2 files changed
+15
-7
No files matched your search
+14
-1
@@ -68,10 +68,23 @@ const FORGEJO_EVENT_NAME_MAP: Record<string, string> = {
|
|||||||
pull_request_comment: "pull_request_review_comment",
|
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<string, string> = {
|
||||||
|
label_updated: "labeled",
|
||||||
|
};
|
||||||
|
|
||||||
function normalizeEventName(eventName: string): string {
|
function normalizeEventName(eventName: string): string {
|
||||||
return FORGEJO_EVENT_NAME_MAP[eventName] ?? eventName;
|
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 = [
|
const AUTOMATION_EVENT_NAMES = [
|
||||||
"workflow_dispatch",
|
"workflow_dispatch",
|
||||||
"repository_dispatch",
|
"repository_dispatch",
|
||||||
@@ -149,7 +162,7 @@ export function parseGitHubContext(): GitHubContext {
|
|||||||
|
|
||||||
const commonFields = {
|
const commonFields = {
|
||||||
runId: process.env.GITHUB_RUN_ID!,
|
runId: process.env.GITHUB_RUN_ID!,
|
||||||
eventAction: context.payload.action,
|
eventAction: normalizeEventAction(context.payload.action),
|
||||||
repository: {
|
repository: {
|
||||||
owner: context.repo.owner,
|
owner: context.repo.owner,
|
||||||
repo: context.repo.repo,
|
repo: context.repo.repo,
|
||||||
|
|||||||
@@ -36,12 +36,7 @@ export function checkContainsTrigger(context: ParsedGitHubContext): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check for label trigger
|
// Check for label trigger
|
||||||
// Forgejo sends "label_updated" instead of "labeled" for issue label events
|
if (isIssuesEvent(context) && context.eventAction === "labeled") {
|
||||||
if (
|
|
||||||
isIssuesEvent(context) &&
|
|
||||||
(context.eventAction === "labeled" ||
|
|
||||||
context.eventAction === "label_updated")
|
|
||||||
) {
|
|
||||||
const labelName = (context.payload as any).label?.name || "";
|
const labelName = (context.payload as any).label?.name || "";
|
||||||
|
|
||||||
if (labelTrigger && labelName === labelTrigger) {
|
if (labelTrigger && labelName === labelTrigger) {
|
||||||
|
|||||||
Reference in new issue
Block a user