Skip to content
GitHub Webhooks Made Easy!
Go
Branch: master
Clone or download
Latest commit 94d97e2 Jun 13, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
cmd/hookah Updates for hmacsig changes Jun 12, 2019
.gitignore Splits library from cmd Dec 22, 2016
.travis.yml Update .travis.yml Aug 29, 2018
LICENSE.md Adds license Jul 7, 2016
README.md Cleans up README Jun 12, 2019
exec.go Small refactor May 9, 2018
go.mod
go.sum Adds go.mod & go.sum Jun 13, 2019
server.go move hmac signing to a dependency Jul 23, 2018

README.md

Hookah

Join the chat at https://gitter.im/hookah-server/Lobby

Go Report Card GoDoc Build Status

Hookah is a simple server for GitHub Webhooks that forwards the hooks messsage to any manner of script, be they PHP, Ruby, Python or even straight up shell.

It simply passes the message on to the STDIN of any script.

Installation

From Source

go get -u -v github.com/donatj/hookah/cmd/hookah

Usage

When receiving a webhook request from GitHub, Hookah checks {server-root}/{vendor}/{product}/{X-GitHub-Event}/* for any executable scripts, and executes them sequentially passing the JSON payload to it's standard in.

This allows actual hook scripts to be written in any language you prefer.

For example, a script server/donatj/hookah/push/log.rb would be executed every time a "push" event webhook was received from GitHub on the donatj/hookah repo.

Example Hook Scripts

bash + jq

#!/bin/bash

set -e

json=`cat`
ref=$(<<< "$json" jq -r .ref)

echo "$ref"
if [ "$ref" == "refs/heads/master" ]
then
        echo "Ref was Master"
else
        echo "Ref was not Master"
fi

PHP

#!/usr/bin/php
<?php

$input = file_get_contents("php://stdin");
$data  = json_decode($input, true);

print_r($data);

Note

Don't forget to make your scripts executable (chmod +x <script filename>), and add a shebang poiting to your desired interpreter (i.e. #!/bin/bash) as the first line.

You can’t perform that action at this time.