I recently automated the deployment of my site to GitHub Pages, which is something that I’ve wanted to do for awhile. Whereas I would previously enter a string of commands into the terminal, I now use Rake to handle those commands for me.
Please Note: I no longer do this, but instead use Grunt Build Control to deploy to GitHub.
What is Rake
For those who don’t know (and this was me until recently), Rake is “a simple ruby build program with capabilities similar to make.” In other words, it’s a tool that helps automate the tedium that often comes with managing a website.
More Info: Jason Seifer has a pretty good Rake Tutorial for developers new to Rake.
I’ve set up Jekyll to consist of two branches: source and master. The source branch consists of the entire project and as such tracks all changes, while the master branch consists solely of the compiled site, which can be found in the _site subdirectory.
My typical workflow is to write a post (or modify the site design) and then commit whatever I’ve changed until the only files that remain uncommitted are in the _site subdirectory. I then stage and commit those files with a generic message that includes the current time.
Here’s what my commit rake task currently looks like, although I’d consult the Rakefile for a more future-proof version.
Once everything is committed I go through the steps I outlined in Deploying Jekyll with Plugins to GitHub Pages. Again, I’d check the Rakefile in the event I change something and forget to update this post.
Commit and Deploy
Finally, I’ve gone ahead and combined them into one task to save myself the burden of typing two separate commands everytime I want to update my website.
Not only have I automated the deployment of my site, but I’ve also used Rake to create development and production builds. This has allowed me to implement Sass source maps and easily minify my assets, which I’ll detail in subsequent posts! Stay tuned :)