I put together a quick fabric script yesterday to deploy this site after growing tired of manually building it and SFTP'ing it over.
An alternative method which I've used in the past would be to setup a Git repo on the server and have a post-recieve hook which builds the site and copies it over, allowing me to deploy via Git push. However, I didn't want to install Ruby on the server if it would only be used for building Jekyll sites.
1 from fabric.api import * 2 3 env.user = 'user' 4 env.hosts = ['host'] 5 6 domain = 'citruspi.io' 7 subdom = 'www' 8 9 def push(): 10 local('jekyll build') 11 local('zip -r _site _site') 12 run('rm -f /srv/%s/_site.zip' % (domain)) 13 run('rm -rf /srv/%s/_site' % (domain)) 14 put('_site.zip', '/srv/%s/_site.zip' % (domain)) 15 run('unzip /srv/%s/_site.zip -d /srv/%s' % (domain, domain)) 16 run('rm -rf /srv/%s/%s' % (domain, subdom)) 17 run('mv /srv/%s/_site /srv/%s/%s' % (domain, domain, subdom))
When you run
$ fab push the script
_site.zipfrom the server if it exists
_site/from the server if it exists
_site.zipto the server
www/and replaces it with
As far as I'm concerned, this is just a temporary measure - I plan to replace this with Ansible or Salt Stack when I get some time, but deploying via fabric till then is pretty nice. I also plan to slowly move my other static sites to Jekyll, allowing me to use my deployment script(s) with as many of my static sites as possible.
Published on 06 February 2014.