You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package main
import (
"fmt""net/http""github.com/go-playground/webhooks/v6/github"
)
const (
path="/webhooks"
)
funcmain() {
hook, _:=github.New(github.Options.Secret("MyGitHubSuperSecretSecret...?"))
http.HandleFunc(path, func(w http.ResponseWriter, r*http.Request) {
payload, err:=hook.Parse(r, github.ReleaseEvent, github.PullRequestEvent)
iferr!=nil {
iferr==github.ErrEventNotFound {
// ok event wasn't one of the ones asked to be parsed
}
}
switchpayload.(type) {
case github.ReleasePayload:
release:=payload.(github.ReleasePayload)
// Do whatever you want from here...fmt.Printf("%+v", release)
case github.PullRequestPayload:
pullRequest:=payload.(github.PullRequestPayload)
// Do whatever you want from here...fmt.Printf("%+v", pullRequest)
}
})
http.ListenAndServe(":3000", nil)
}
Contributing
Pull requests for other services are welcome!
If the changes being proposed or requested are breaking changes, please create an issue for discussion.
License
Distributed under MIT License, please see license file in code for more details.
About
🎣 Webhook receiver for GitHub, Bitbucket, GitLab, Gogs