Skip to content

Commit

Permalink
Respond to ping event
Browse files Browse the repository at this point in the history
  • Loading branch information
arnested committed Jul 17, 2019
1 parent 82b7c44 commit d10017e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion webhook/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 {
Expand Down

0 comments on commit d10017e

Please sign in to comment.