05 December 2015 0 comments Python, Web development, Django, ReactJS, JavaScript
Headsupper.io is a free GitHub webhook service that emails people when commits have the configurable keyword "headsup" in it.
Headsupper.io is great for when you have a GitHub project with multiple people working on it and when you make a commit you want to notify other people by email.
Basically, you set up a GitHub Webhook, on pushes, to push to https://headsupper.io
and then it'll parse the incoming push and its commits and look for certain things in the commit message. By default, it'll look for the word "headsup". For example, a git commit message might look like this:
fixes #123 - more juice in the Saab headsup! will require updating
Or you can use the multi-line approach where the first line is short and sweat and after the break a bit more elaborate:
bug 1234567 - tea kettle upgrade 2.1 Headsup: Next time you git pull from master, remember to run peep install on the requirements.txt file since this commit introduces a bunch of crazt dependency changes.
Git commits that come through that don't have any match on this word will simply be ignored by Headsupper.
Maybe paradoxically, you need to authenticate with your GitHub account but that's in read-only mode and does NOT set up the Webhook for you. The reason you have to authenticate to prepare a configuration on headsupper.io is to tie the configuration to a real user.
Once you've authenticated you get the option to create your first configuration, then you have to enter at least these three piece of information:
peterbe/django-peterbecom
or mozilla/socorro
.Once you've set that up, you'll need to go to your GitHub project's Setting page and enter a new Webhook and the URL you need to type in is https://headsupper.io
and for the "Secret" type in that secret you used earlier. That's it!
The word that triggers is configurable by you. The default is headsupper
. And by default, it's case insensitive. You can change that so it's case sensitive. Also, the word has to be word delimited on the left (e.g. a space or a newline character) and on the right it needs to be a space, a :
or a !
. So this won't match:
theheadsup:
or headsupper
.
Other optional things you can configure are:
master
)That last option, Only send when a new tag is created, is interesting. I added that option because at work, we make production server releases by pushing a git tag. When a tag is pushed, all those commits are sent to the continuous deployment service which makes a server upgrade. This means you get a chance to enter a heads up message to be emailed to the people who care about new deployments going out.
It's a mix between Django and ReactJS. The whole client-side app it built statically with Webpack in ES6. It's served as static files through Nginx. But Nginx is making an exception on all URLs that start with /api
or /accounts
. The /api/*
it used for loading and setting JSON. The /accounts/*
is used for the GitHub OAuth endpoints.
What's interesting about this the architecture is that it's using HTTP cookies. Not API tokens. Cookies are quite good in that they're established and the browser does all the automated work of keeping it secure and making each request potentially authenticated.
Here's the relevant React code and here's the relevant Django code that processes the Webhook.
The whole project is available on: https://github.com/peterbe/headsupper.
Also, I made a demo at the November Mozilla Beer and Tell.