mirror of
https://github.com/lukaszraczylo/ghtracker.git
synced 2026-10-18 01:27:30 +00:00
feat(web): add opt-in webhook alert actions
An optional actions block in the config adds buttons to alerts. POST
/api/actions/{id} checks that the repository and the current alert match,
then sends the alert as JSON to the configured webhook with an optional
bearer token. The request refuses cross-site callers like POST /refresh.
GET /api/state lists the actions and merges per-alert status rows from an
optional status_url, cached for 10 seconds. Without an actions block the
API output does not change.
The ghtracker_action_requests_total counter records each result.
This commit is contained in:
@@ -80,6 +80,10 @@ func run(ctx context.Context, cfgPath string, log *slog.Logger) error {
|
||||
}
|
||||
srv := web.New(coll, promhttp.HandlerFor(reg, promhttp.HandlerOpts{}), ui, *cfg.ManualRefresh, log)
|
||||
|
||||
if len(cfg.Actions) > 0 {
|
||||
srv.WithActions(web.NewActions(cfg.Actions, log, reg))
|
||||
}
|
||||
|
||||
go coll.Run(ctx)
|
||||
|
||||
hs := &http.Server{Addr: cfg.Listen, Handler: srv.Handler(), ReadHeaderTimeout: headerTimeout}
|
||||
|
||||
Reference in New Issue
Block a user