Continuous Deployment of a Jekyll Site with Travis CI and Aerobatic

February 06, 2017

With the new Aerobatic CLI, it's now possible to host any static site using any CI tool, and the repo need not be hosted with Bitbucket. In this example, we'll set up continuous deployment of a Jekyll site whose repository is hosted on GitHub, using Travis CI.

From the Jekyll Themes site, pick a theme and fork it in GitHub.

Then, clone that repository onto your local disk.

  1. Go to your profile on travis-ci.org: https://travis-ci.org/profile/username
  2. Find the repository for which you’re interested in enabling builds.
  3. Click the slider on the right so it flips from a grey "X" to a green "✓".

In the root of your repository, create a new file called travis.yml.

cd my-jekyll-site
language: ruby
env:
  global:
    - secure: AEROBATIC_API_KEY
    - TRAVIS_NODE_VERSION="6.9.5"

install:
  - rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm install $TRAVIS_NODE_VERSION
  - npm install aerobatic-cli -g
  - bundle install --path vendor/bundle

script:
  - echo "url: https://!!baseurl!!" >> _config.yml
  - bundle exec jekyll build

after_success:
  - aero deploy -d _site

We now need to associate the repo with Aerobatic by creating the site. Assuming you have already installed the Aerobatic CLI:

cd my-jekyll-site
aero create

An environment variable named AEROBATIC_API_KEY needs to be set in the build script in order to make authenticated calls to the Aerobatic API. Each CD service has a mechanism for setting environment variables. It’s recommended that the value be encrypted if your service supports it. Travis provides a command line tool for encrypting a variable and injecting it into the travis.yml file.

aero apikey
gem install travis
travis encrypt AEROBATIC_API_KEY=<super_secret> --add env.matrix

To get your AEROBATIC_API_KEY to insert into the placeholder <super_secret>, you can run the aero apikey command.

At this point, you're ready to commit your code and let Travis build the Jekyll site for you

git add --all
git commit -m "Set up Travis build"
git push origin master

As a reminder, if you run aero info, you'll get your production URL. You can also rename the site if you so wish with the aero rename command.