From 8b053fd7dc0bb59a55a78bec32999f8a4be5df53 Mon Sep 17 00:00:00 2001 From: Ariejan de Vroom Date: Mon, 25 Mar 2013 11:55:51 +0100 Subject: [PATCH] Add 2013-03-25-automated-nanoc-deployments --- .../2013-03-25-automated-nanoc-deployments.md | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 content/posts/2013-03-25-automated-nanoc-deployments.md diff --git a/content/posts/2013-03-25-automated-nanoc-deployments.md b/content/posts/2013-03-25-automated-nanoc-deployments.md new file mode 100644 index 0000000..d56946d --- /dev/null +++ b/content/posts/2013-03-25-automated-nanoc-deployments.md @@ -0,0 +1,55 @@ +--- +title: "Automated nanoc deployments" +kind: article +created_at: 2013-03-25 +tags: + - nanoc + - automation + - jenkins + - gitlab +--- +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: + +1. Write stuff in Markdown +2. Commit and push +3. Watch how jenkins builds and publishes the site with nanoc and rsync. + +## Using nanoc + +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. + +## Enter gitlab + +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. \ No newline at end of file