Quick file overview:
18f-site.conf
- Our nginx config for the production and staging site. Not synced to version control automatically, but we'll try to keep them in sync.fabfile.py
- Fabric deployment script to start/stop/restart our webhook processes. Could be extended to deploy and sync our nginx config, and restart nginx.hookshot.js
- Tiny webhook app, runs a command when a branch is updated. Useshookshot
to do the heavy lifting. Daemonized on our server usingforever
.
On the staging and production server, this project uses Node and hookshot
to receive GitHub post-receive webhooks and update the project.
Ideally, these webhooks just run forever and never need to be maintained!
But just in case, this project includes fabric tasks for easy remote stop/start/restart of the hook processes on the 18F website.
You will need:
- authorized access to the 18F site server
- an
18f-site
entry in your$HOME/.ssh/config
with the necessary credentials - to
pip install fabric
, and have your activepython
when running it be 2.X
With that, you can start, stop, and restart the staging and production hooks like so:
fab stop
fab start
fab restart
Provide --set env=production
to any of those commands to apply it to the production hook.
These instructions can be applied locally (for development) or on the server (for deployment).
Install the Node dependencies with:
npm install hookshot
npm install minimist
npm install -g forever
18F's web server uses the hookshot
command to listen for hooks on either of two ports.
From /deploy
, run the hook with the appropriate port and command. It can be helpful to have forever
and your command both log to the same file.
In development, you might use:
forever start -l $HOME/hookshot.log -a deploy/hookshot.js -p 3000 -b your-branch -c "cd $HOME/18f/18f.gsa.gov && git pull && jekyll build >> $HOME/hookshot.log"
You can stop and restart your hooks by supplying the same arguments you gave.
forever stop deploy/hookshot.js -p 3000 -b your-branch -c "cd $HOME/18f/18f.gsa.gov && git pull && jekyll build >> $HOME/hookshot.log"
forever restart deploy/hookshot.js -p 3000 -b your-branch -c "cd $HOME/18f/18f.gsa.gov && git pull && jekyll build >> $HOME/hookshot.log"
On our web server, 18F runs two separate hooks.
You may wish to use ngrok or localtunnel in development, to test out the webhook.