Automated nanoc deployments
I’ve migrated ariejan.net from a custom Ruby on Rails application to a statically generated site with Nanoc.
Publishing my site now goes like this:
- Write stuff in Markdown
- Commit and push
- Watch how jenkins builds and publishes the site with nanoc and rsync.
Nanoc is a very powerful static site generator. You can use ruby to create helpers, filters and what not. Fancy using Sass, Compass and Haml? No problem!
Simply write pages in Haml or Markdown and Nanoc will generate a complete site, including sitemap, robots.txt and RSS feed.
Once you’ve set everything up to your liking, simply run
nanoc compile and your site is ready.
Nanoc also has some nice features to deploy your website through rsync, which will upload (or remove) files on a remote server as necessary.
Automate the crap out of it!
I’m a programmer. I like to automate repetitive tasks. So I did.
I’ve setup Jenkins with the RVM plugin and that’s all I need to have Jenkins generate and deploy my Nanoc site.
Here’s the build script I currently use:
#!/bin/bash export NANOC_ENV=production bundle install nanoc compile nanoc deploy -t public
If the compilation fails for some reason, the deployment is cancelled.
Now I use Gitlab to host tons of private repositories, including the one for ariejan.net.
I’ve setup a web hook that will trigger the Jenkins job when new commits are made or pushed.
This allows me to quickly edit a file, commit it and Gitlab en Jenkins will make sure the change is compiled and published to ariejan.net.
Where to go from here
For now, this setup suffices for me. I keep all my posts in version control, and backupped to S3 (by backing up my gitlab repositories). Adding a new story to git is sufficient for it to be published automatically on ariejan.net and in the event something goes wrong with compilation, Jenkins will notify me of the build failure.