From 1feec26c2e4169e464abeedb7a22eec0a3ded2d5 Mon Sep 17 00:00:00 2001 From: Vlad Mocanu Date: Thu, 26 Feb 2026 10:29:00 +0200 Subject: [PATCH] feat: check trigger label on issue opened events When an issue is created with the trigger label already applied, Forgejo only fires issues/opened (not a separate labeled event). Check payload.issue.labels for the trigger label during opened events so creating an issue with the claude label works in one step. Co-Authored-By: Claude Opus 4.6 --- src/github/validation/trigger.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/github/validation/trigger.ts b/src/github/validation/trigger.ts index c16cdf1..e07482b 100644 --- a/src/github/validation/trigger.ts +++ b/src/github/validation/trigger.ts @@ -45,8 +45,21 @@ export function checkContainsTrigger(context: ParsedGitHubContext): boolean { } } - // Check for issue body and title trigger on issue creation + // Check for issue body, title, and label trigger on issue creation if (isIssuesEvent(context) && context.eventAction === "opened") { + // Check if the issue was created with the trigger label already applied + if (labelTrigger) { + const issueLabels: Array<{ name?: string }> = + (context.payload.issue as any).labels ?? []; + const hasLabel = issueLabels.some((l) => l.name === labelTrigger); + if (hasLabel) { + console.log( + `Issue opened with trigger label '${labelTrigger}' already applied`, + ); + return true; + } + } + const issueBody = context.payload.issue.body || ""; const issueTitle = context.payload.issue.title || ""; // Check for exact match with word boundaries or punctuation