Giter VIP home page Giter VIP logo

hook-receiver's Introduction

Github WebHook Receiver and Command Runner

This project is a simple web server which will receive Github WebHooks and then run a command based on the payload.

Config

When the server starts, it reads from config.json which should be located in the same directory as the binary. The config file has the following properties.

Property Required Description
port yes The port that the server runs on
rules[][criteria][][type] yes Type of Github Event
rules[][criteria][][owner] no Repository Owner
rules[][criteria][][repository] no Name of repository
rules[][command] yes Command to run if the criteria matches
cidr_override no All requests received by the server are checked to make sure the requesting IP matches the given CIDR. If cidr_override is not specified, Github's CIDR is used

Example Config

{
    "port": 8000,
    "rules": [
        {
            "_comments": "Update the Satis packages whenever code is pushed to a robstrong repo",
            "command": "php /opt/satis/bin/satis build /opt/satis/satis.json /srv/www -n",
            "criteria": [
                {
                    "event": "push",
                    "owner": "robstrong"
                }
            ]
        },
        {
            "_comments": "Update the issues page when an issue is updated/created",
            "command": "/opt/github-history/go-gh-history -o /srv/www/issues.html issues robstrong/hook-receiver",
            "criteria": [
                {
                    "event": "issues",
                    "owner": "robstrong",
                    "repository": "hook-receiver"
                }
            ]
        },
        {
            "_comments": "Pull down branches starting with 'release-' locally when pushed",
            "command": "cd ~/go-github-history/ && git checkout {{ .Branch }} && git pull origin {{ .Branch }}",
            "criteria": [
                {
                    "event": "push",
                    "owner": "robstrong",
                    "repository": "go-github-history",
                    "push_params": {
                        "branch": "release-*"
                    }
                }
            ]
        }
    ]
}

Templating

The command that is run will be evaluated as a template. The payload data will be passed to the template. So you can use data from the Github hook in your command. For example, if you received a push event, you could setup a command like this:

"fabric deploy_branch:{{.Branch}}

You can see what data is available in the action_event.go (push_event.go, release_event.go, etc).

Functions

Currently there is only one template function:

after - will return the string that comes after the string that is passed in

If Branch = "release-myNewFeature"

{{ .Branch | after "release-" }}

Would output "myNewFeature"

hook-receiver's People

Contributors

robstrong avatar

Stargazers

 avatar

Watchers

 avatar  avatar

hook-receiver's Issues

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.