Add label trigger functionality to Claude Code Action

- introduced a new input parameter `label_trigger` in `action.yml` to allow triggering actions based on specific labels applied to issues.
- Enhanced the context preparation and event handling in the code to support the new labled event.
This commit is contained in:
tomoish
2025-06-17 00:32:12 +09:00
parent 3c748dc927
commit 90b0a15006
10 changed files with 182 additions and 2 deletions

View File

@@ -12,7 +12,7 @@ import type { ParsedGitHubContext } from "../context";
export function checkContainsTrigger(context: ParsedGitHubContext): boolean {
const {
inputs: { assigneeTrigger, triggerPhrase, directPrompt },
inputs: { assigneeTrigger, labelTrigger, triggerPhrase, directPrompt },
} = context;
// If direct prompt is provided, always trigger
@@ -33,6 +33,16 @@ export function checkContainsTrigger(context: ParsedGitHubContext): boolean {
}
}
// Check for label trigger
if (isIssuesEvent(context) && context.eventAction === "labeled") {
const labelName = (context.payload as any).label?.name || "";
if (labelTrigger && labelName === labelTrigger) {
console.log(`Issue labeled with trigger label '${labelTrigger}'`);
return true;
}
}
// Check for issue body and title trigger on issue creation
if (isIssuesEvent(context) && context.eventAction === "opened") {
const issueBody = context.payload.issue.body || "";