feat: fire automations from GitHub events
Completes the loop. A GitHub delivery is recorded, matched against the org's enabled triggers, and dispatched as a run. Until now a trigger could be saved but nothing read it.
Supersedes the util-only version of this PR — that had no caller, so there was nothing to actually review.
No migration: automation_runs.trigger_id / event_id and a nullable scheduled_for were added in the earlier migration and finally have writers.
The path
GitHub delivery
→ ingest.webhook_events (existing, unchanged)
→ automation_events (normalized, org resolved via installation)
→ match enabled github triggers for that org
→ QStash → /api/automations/dispatch/:id { triggerId, eventId }
→ automation_runs (scheduled_for null, trigger_id + event_id set)
Two deliberate inversions in matching
An unconfigured scope matches nothing. Usually an empty filter means unrestricted. Here null is a closed door, because the failure it prevents is worse: a half-built trigger silently firing on every repository in the org. Branches and labels are the documented exception — null there means the author chose not to filter.
A regex that does not compile matches nothing, so a typo narrows rather than widens.
One delivery, several named events
| delivery | matches |
|---|---|
pull_request.opened, draft: true | draft_opened |
pull_request.opened otherwise | pull_request.opened |
| review submitted, approved | pr_review_submitted.any and .approved |
| workflow run failed | workflow_run.any and .failure |
This is why the schema names these separately rather than one event plus a filter — "any review" and "approved only" must both fire on one delivery.
What stops it running away
- Disabled automations are skipped. That toggle is the gate a person actually controls, so pausing an automation stops it without disabling each trigger.
- Duplicates die twice before a run exists: a redelivered GitHub delivery is swallowed by the
automation_eventsdedupe and never reaches matching, and QStash dedupes ontriggerId_eventId. - Recording and dispatch run outside the existing processing
try, so a failure here can't fail a delivery GitHub would retry. - Nothing has event triggers configured yet — the editor UI doesn't exist — so the live blast radius today is zero.
Verified
13 matching cases: repository scoping including null and any; regex hit, miss and invalid; case-insensitive substring; actor allow-list; me resolving to the automation owner and rejecting others; subjectAuthor filtering independently of actor; wrong event kind. Plus the four mappings above, and the event recorder's normalization and dedupe from the previous PR.
Each rejection carries a reason (repository, actor, commentFilter, …), which is what will make "why didn't my automation run" answerable.
Typecheck, lint and the full suite pass.
Known gap
me resolves against automations.ownerUserId, which is a Superset user id, while the event carries a GitHub login. That comparison won't match until GitHub identities are linked to users — so me behaves as "nobody" today rather than misfiring. Worth fixing with the editor work, when there's a way to pick people at all.
Summary by CodeRabbit
-
New Features
- Added reliable automation-trigger matching across normalized GitHub event types.
- Added filtering by repository, branch, labels, actors, subject authors, fork status, and comment content.
- Added automatic dispatch of matching automations from GitHub webhook events.
- Added support for event-triggered automation runs alongside scheduled runs.
- Exposed automation-matching capabilities for shared application features.
-
Updates
- Limited configurable comment and message filters to case-insensitive literal text matching.