I have a server setup with a headless git repo and non-headless one. When I push to the headless repo, the post-receive hook goes to the other repo, pulls from the headless, runs tests and restarts the server
So to deploy I just do
git push deploy master
And get instant feedback that all the tests passed and server was restartedI always found that the hook never really worked for some bizarre reason. Even something as simple as:
cd /home/deployer/wordpress/wp-content/themes/my-theme && git pull origin master
failed.
My hook is:
cd $REPO_DIR
unset GIT_DIR
unset GIT_WORK_TREE
git checkout deploy && \
git stash && \
git pullWe also never SSH into a server, and instead use Capistrano to handle this for us. Capistrano works great with Rails, but even other frameworks have plugins to handle this. And if you're new to capistrano, take a look at http://capo.io (shameless plug: we built this) for readily available recipes for all kinds of tasks. We use Capo for all our projects, ranging from static sites to jekyll to sinatra, rack and rails apps.
I wrote a quick fabfile yesterday that automatically commits/merges my local changes, pushes to a private GitHub repo, then SSHs into my production server, pulls down the latest code and restarts the web server. Gives me feedback along the way too.
Don't use fabric for deployment (even though it's a fantastic tool for many use cases).
The only changes I'd make would be to wrap it up in a script so you have one-click deploys, and possibly implement the 'copy and symlink' strategy that Capistrano uses so you have minimal downtime during deploys and instant roll-backs if necessary.
However, with all these people talking about deployment, I just wanna hijack (sorry!) and ask if anybody can help with my current deployment setup:
- Branch into a new feature (refactor-javascript for example) - Commit constantly - Rebase with master then merge into master - Push to remote repo - SSH to server, and then pull from the same repo - (.git isn't exposed via HTTP)
What's the better way of doing this? If you could help that'd be great :-) Drop me an email at [email protected]