From d10017e1b35c62e6858dc43d5ae8004c4e1a2dec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20J=C3=B8rgensen?= Date: Wed, 17 Jul 2019 09:58:12 +0200 Subject: [PATCH] Respond to ping event --- webhook/function.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/webhook/function.go b/webhook/function.go index 8e6f426..e04307d 100644 --- a/webhook/function.go +++ b/webhook/function.go @@ -38,7 +38,7 @@ func Handle(w http.ResponseWriter, r *http.Request) { } hook, _ := github.New(github.Options.Secret(githubSecret)) - payload, err := hook.Parse(r, github.PullRequestEvent) + payload, err := hook.Parse(r, github.PullRequestEvent, github.PingEvent) if err == github.ErrMissingHubSignatureHeader { http.Error(w, fmt.Sprintf("%s: %s", http.StatusText(http.StatusUnauthorized), err), http.StatusUnauthorized) @@ -52,6 +52,12 @@ func Handle(w http.ResponseWriter, r *http.Request) { return } + if _, ok := payload.(github.PingPayload); ok { + http.Error(w, "Pong", http.StatusOK) + + return + } + pullRequest, ok := payload.(github.PullRequestPayload) if !ok {