Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: respond to GitHub ping event (#2332)
h3n4le05cd22164c5
diff --git a/plugin/vcs/github/github.go b/plugin/vcs/github/github.goindex 619d6be2a6..43a132ac16 100644--- a/plugin/vcs/github/github.go+++ b/plugin/vcs/github/github.go@@ -122,6 +122,8 @@ type WebhookType stringconst (// WebhookPush is the webhook type for push.WebhookPush WebhookType = "push"+ // WebhookPing is the webhook type for ping.+ WebhookPing WebhookType = "ping")// WebhookInfo represents a GitHub API response for the webhook information.diff --git a/server/webhook.go b/server/webhook.goindex 8c30f59972..10195ce240 100644--- a/server/webhook.go+++ b/server/webhook.go@@ -128,6 +128,14 @@ func (s *Server) registerWebhookRoutes(g *echo.Group) {// This shouldn't happen as we only setup webhook to receive push event, just in case.eventType := github.WebhookType(c.Request().Header.Get("X-GitHub-Event"))++ // https://docs.github.com/en/developers/webhooks-and-events/webhooks/about-webhooks#ping-event+ // When we create a new webhook, GitHub will send us a simple ping event to let us know we've set up the webhook correctly.+ // We respond to this event so as not to mislead users.+ if eventType == github.WebhookPing {+ return c.String(http.StatusOK, "OK")+ }+if eventType != github.WebhookPush {return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid webhook event type, got %s, want %s", eventType, github.WebhookPush))}