inspired by Github-Auto-Deploy
our servers are only accessible via VPN and auto deployment from CI SaaS wasn't an option for us.
This is a simple HTTP server that receive commit info from github and deploy app to servers with your faborite script (bash, fabric, saltstack)
It also provides nice logging and security
In our shop, once code is pushed, codeship will run tests and coverall will check code coverage etc...
Then manual code review is done by human and reviewer will merge the code to master
Once code is merged to master, we were running fabric script to deploy. This is the part we wanted to automate and this code I hope to help faciliate that.
You can set up Post-Receive Hooks on github. Whenever the repository is pushed, it post repo info (shown below) to this auto deploy server and run your deploy script.
{ :before => before, :after => after, :ref => ref, :commits => [{ :id => commit.id, :message => commit.message, :timestamp => commit.committed_date.xmlschema, :url => commit_url, :added => array_of_added_paths, :removed => array_of_removed_paths, :modified => array_of_modified_paths, :author => { :name => commit.author.name, :email => commit.author.email } }], :repository => { :name => repository.name, :url => repo_url, :pledgie => repository.pledgie.id, :description => repository.description, :homepage => repository.homepage, :watchers => repository.watchers.size, :forks => repository.forks.size, :private => repository.private?, :owner => { :name => repository.owner.login, :email => repository.owner.email } } }
- Install auto deploy server
git https://github.com/naoko/github-auto-deploy.git cd github-auto-deploy pip install -r requirements.txt python deploy-server.py
- Test (optional) setup post-receive hooks. You can test webhooks by following this instrcution. Paste raw
curl -i -d 'payload=xxxx'
- in fabfile, moidfy env.hosts and env.user
- generate ssh key on server
- copy public key to server. you can use push_pub_key in fabfile. This command will copy local public key to ~/.ssh/authorized_keys on server.
fab push_pub_key
- Currently it checks to see if request IP is from github
- We recommend to use HTTPS for webhook
more security
yes more yep yep