Deployment to GitHub Pages Is Introduced

There have been three weeks since we made the first public release of Grain, and we’re back to share some release news with you. First of all, we’d like to thank everyone who showed interest in our product and helped by making early contributions or posting thoughtful feedback. Your help is really valuable to us.

Over the last few days, we have released version 0.5.1 of Grain and versions 0.3.3 of Octopress and Template themes. You can check out the latest versions and the complete changelog on the release pages of these projects. The latest Octopress theme is available here, and the Template theme is available here.

With Grain 0.5.1, we introduced a small but important feature: you can now set closures to be executed as deploy commands. To put it shortly, now you can simply write this in the SiteConfig.groovy file of any Grain theme:

deploy = {
  //put custom deploy logic here
}

And then the logic, encapsulated in the closure, will be executed when you call standard ./grainw deploy from the command line.

The described feature was used in the new releases of Octopress and Template themes to introduce smooth integration with the GitHub Pages service. Now, deploying your site to GitHub will take no time and will consist of a few simple steps:

  • Create a repo on GitHub that you want to deploy your site to. When creating a repo, follow the rules described on the service’s homepage: name repo username.github.io if you want to create a personal/organization page, or name repo by project name, for a project site. There’s nothing else you need to do beforehand.
  • Set gh_pages_url property in SiteConfig.groovy to the link to the created repo. The link should be provided in the following format: git@github.com:username/repo.git
  • Make sure deploy property in SiteConfig.groovy points at the closure returned by the expression: new GHPagesDeployer(site).deploy.
  • Make sure that url property in prod settings of environments section of SiteConfig.groovy is set to the future URL. Your site will be available at username.github.io if you are deploying a user/organization page, or at username.github.io/repo if you are deploying a project site.
  • Call ./grainw deploy to deploy the already generated site, or call ./grainw gendeploy to generate and deploy. Your site will be up in a few minutes since then.

As always, we’d love to hear feedback or questions, and we’d appreciate any reports of issues.