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 <noreply@anthropic.com>
This commit is contained in:
Vlad MocanuandClaude Opus 4.6 committed 2026-02-26 10:29:05 +02:00
1 parent b37009b766
commit 1feec26c2e
1 file changed
+14 -1
+14 -1
View File
@@ -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