18F/foia-hub — pull request #168 by konklone (2014-10-27 23:35:09+00:00)
Title: Webhook for auto-deployment of site

This sets up a light webhook system that, when run, runs a [`hookshot`](https://github.com/coreh/hookshot) listens on a port for any changes to a given branch and runs a given command. I'm running it on the staging server on port 3000, listening for pushes to `master`. I've been testing it out on `hookshot`, but at PR-filing-time it's listening for changes to `master`.

If you have admin privileges, you can go to this repo's settings and [see the webhook](https://github.com/18F/foia-hub/settings/hooks/3317369). It posts to `https://foia.18f.us/deploy`, which hits an endpoint I added to our nginx config that proxies directly to the `hookshot` daemon.

Details on starting the hook are kept in documentation, in `deploy/README.md`. I intend to eventually add a second `fabfile.py` just to manage webhook stop/start/restart, but that can come later.

When the hook is hit, it will execute a small bash script, also included in `deploy/README.md`, that triggers a fabric deploy to `localhost`. I've configured the `foia` user to be able to SSH into itself without warnings.

This has a lot of files, because I'm vendoring the two Node dependencies in `node_modules`. I could set up a more sophisticated system, where I symlink `node_modules` to something maintained in the server's `shared/`dir or something, but this seemed simpler to start.

I'm merging this PR myself to test out the hook on its intended branch, while I'm around to watch. It's possible there will be a follow-up PR if things are off.