Skip to content

fix: support push event in automation context#1457

Open
tombrov wants to merge 1 commit into
anthropics:mainfrom
tombrov:push-event-additions
Open

fix: support push event in automation context#1457
tombrov wants to merge 1 commit into
anthropics:mainfrom
tombrov:push-event-additions

Conversation

@tombrov

@tombrov tombrov commented Jun 30, 2026

Copy link
Copy Markdown

Summary

Adds push to the list of supported GitHub event types so the action can be driven from on: push: workflows (e.g. post-merge automation that regenerates artifacts after a merge to main).

Before this change, parseGitHubContext() threw Unsupported event type: push at startup, blocking any non-PR/non-issue automation use case where workflow_dispatch isn't a good fit.

What changed

  • src/github/context.ts
    • Import PushEvent from @octokit/webhooks-types.
    • Add "push" to AUTOMATION_EVENT_NAMES (same bucket as workflow_dispatch, schedule, workflow_run, repository_dispatch).
    • Add PushEvent to the AutomationContext.payload union.
    • Handle case "push": in the parseGitHubContext() switch.
  • test/github-context.test.ts
    • New push produces an automation context test in the automation-events block.
    • Extend the isEntityContext / isAutomationContext type-guard assertions to cover push.

isAutomationContext() is derived from AUTOMATION_EVENT_NAMES, so adding "push" to that tuple makes the type guard recognize it automatically — no other code paths needed changes.

Why this approach

  • No new input flag. Push fits cleanly into the existing automation-event bucket. Agent mode is already triggered by the presence of a prompt: input, which is how workflow_dispatch / schedule users drive the action today.
  • No changes to src/create-prompt/index.ts. The second Unsupported event type throw lives in tag mode's prompt builder, and tag mode requires an entity context (gated via isEntityContext in detectMode() and run.ts). Push events never reach that switch, so the throw stays as-is to preserve the tag-mode invariant.
  • Entity-only code paths are already gated. checkWritePermissions, restoreConfigFromBase, and updateCommentLink in run.ts are all wrapped in isEntityContext(context) checks, so they correctly skip on push events.

Behavior

With this change, a workflow like:

on:
  push:
    branches: [main]
jobs:
  claude:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: anthropics/claude-code-action@v1
        with:
          prompt: "Regenerate ingestion docs from the latest commit"
          claude_args: --max-turns 1

…now runs Claude in agent mode (no tracking comment, no PR/issue anchor required), matching how workflow_dispatch already works.

Test plan

  • bun run typecheck passes
  • bun test test/github-context.test.ts passes (new push cases + existing automation events)
  • bun test full suite green
  • bun run format:check clean
  • Smoke test in a downstream repo: a workflow triggered by on: push: branches: [main] reaches Claude and runs the supplied prompt (instead of failing at startup)

Fixes #1456

@tombrov

tombrov commented Jun 30, 2026

Copy link
Copy Markdown
Author

@wolffiex @km-anthropic I noticed it was pushed before and removed, would love seeing if this could be merged asap for the next release

Tested as a standalone in my actions and I can approve it does work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unsupported event type: push — action exits 1 on push-triggered workflows

6 participants