Travis webhook library to make leveraging the payload information EASY with go
It makes handling the web hook really easy!
isPrivateRepo := true
err := travis.ValidateSignature(isPrivateRepo, r)
if err != nil {
//Handle Invalid Sig
}
webhook, err := travis.NewFromRequest(r)
if err != nil {
//Handle Invalid webhook parsing
}
if webhook.ShouldDeploy() {
//Deploy the application
}
There are a few built in hooks. If you want your own tests for Deployment you can set a new function to be used during ShouldDeploy
.
This replaces the current logic. The default checks that it is on the master branch, it was successful, and that it is not a pull request.
travis.ShouldDeployFn = func (w travis.Webhook) bool {
w.Branch = "develop" &&
w.IsPullRequest = false
}
This is in addition to the current logic. The default only checks the branch, repo, and owner for match.
travis.IsMatchFn = func (w travis.Webhook) bool {
w.
}
The match can be checked like so:
webhook, err := travis.NewFromRequest(r)
if err != nil {
//Handle Invalid webhook parsing
}
if !webhook.IsMatch(){
//Handle lack of match
}