Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/github/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type {
PullRequestReviewEvent,
PullRequestReviewCommentEvent,
WorkflowRunEvent,
PushEvent,
} from "@octokit/webhooks-types";
import { CLAUDE_APP_BOT_ID, CLAUDE_BOT_LOGIN } from "./constants";
// Custom types for GitHub Actions events that aren't webhooks
Expand Down Expand Up @@ -65,6 +66,7 @@ const AUTOMATION_EVENT_NAMES = [
"repository_dispatch",
"schedule",
"workflow_run",
"push",
] as const;

// Derive types from constants for better maintainability
Expand Down Expand Up @@ -111,14 +113,15 @@ export type ParsedGitHubContext = BaseContext & {
isPR: boolean;
};

// Context for automation events (workflow_dispatch, repository_dispatch, schedule, workflow_run)
// Context for automation events (workflow_dispatch, repository_dispatch, schedule, workflow_run, push)
export type AutomationContext = BaseContext & {
eventName: AutomationEventName;
payload:
| WorkflowDispatchEvent
| RepositoryDispatchEvent
| ScheduleEvent
| WorkflowRunEvent;
| WorkflowRunEvent
| PushEvent;
};

// Union type for all contexts
Expand Down Expand Up @@ -233,6 +236,13 @@ export function parseGitHubContext(): GitHubContext {
payload: context.payload as unknown as WorkflowRunEvent,
};
}
case "push": {
return {
...commonFields,
eventName: "push",
payload: context.payload as unknown as PushEvent,
};
}
default:
throw new Error(`Unsupported event type: ${context.eventName}`);
}
Expand Down