Giter VIP home page Giter VIP logo

ghook's Introduction

ghook godoc

ghook is a small Go package for receiving GitHub web hooks.

Example usage:

package main

import (
    "fmt"
    "net/http"

    "github.com/alexbakker/ghook"
)

var (
    secret = []byte("d696f82431664d9ea93483789db0116c")
)

func main() {
    hook := ghook.New(secret, func(event *ghook.Event) error {
        fmt.Printf("received %s event!\n", event.Name)
        return nil
    })

    panic(http.ListenAndServe("127.0.0.1:8080", hook))
}

You can then use the go-github package to parse the payload.

github-hook-receiver

An example usecase for ghook is cmd/github-hook-receiver. It's a simple HTTP service that receives hooks and handles them according to a list of handlers defined in a config file.

Usage of github-hook-receiver:
  -addr string
    	address to listen on (default "127.0.0.1:8080")
  -config string
    	the filename of the configuration file (default "config.json")

The configuration file should have the following format:

{
    "secret": "d696f82431664d9ea93483789db0116c",
    "handlers": [
        {
            "repo": "alexbakker/site",
            "ref": "refs/heads/master",
            "command": "/usr/local/bin/update-blog"
        }
    ]
}

ghook's People

Contributors

alexbakker avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.