Skip to content

Travis webhook library to make leveraging the payload information EASY with go

License

Notifications You must be signed in to change notification settings

tiger5226/travis.go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

travis.go

Travis webhook library to make leveraging the payload information EASY with go

Usage

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.

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
}

IsMatch

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
}

About

Travis webhook library to make leveraging the payload information EASY with go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages