No Hassle Blog Automation - A New Hope

No more servers.

In this third installment of my No Hassle Blog Automation series, I remove the necessity for running any infrastructure of my own. Drone has been replaced with a hosted solution at CircleCI. Their support is amazing, and their circle.yml format made configuration easy. Take a look at the first and second installments of this series.

Requirements

There are a few requirements for this setup:

  • Rackspace Cloud Account
  • Cloud Files Container*
  • Existing Pelican Blog
  • GitHub Account

* This container should be configured to serve a static site.

circle.yml

This file is used by CircleCI to define the test and build process. You can find my current circle.yml file in my repository.

test:
  override:
    - make html
deployment:
  production:
    branch: master
    commands:
      - turbolift -u $RAXUSER -a $RAXAPIKEY --os-rax-auth $RAXREGION upload -s $HOME/$CIRCLE_PROJECT_REPONAME/output -c $CONTAINER

There are two sections to this file:

  • test: This defines the commands to run to test your code. In this instance, we are simply running the make html command provided by Pelican.
  • deployment: This defines the commands to run if tests pass successfully. In this case, if tests pass on the master branch, it will issue the turbolift command.

You will need to set the following environment variables in the CircleCI Project configuration:

  • RAXUSER - Rackspace Cloud user name.
  • RAXAPIKEY - Rackspace Cloud api key.
  • RAXREGION - Cloud Files region where your container is located.
  • CONTAINER - Name of your Cloud Files container.

requirements.txt

You will also need to add a requirements.txt file to your Pelican blog repository. CircleCI will look at this file and install the listed pip packages. The contents should look like this:

pelican
Markdown
turbolift

This is much easier than manually installing things via pip myself.

Setup

Here is a high level overview of the setup steps:

  1. Create a container in Cloud Files, and make sure you configure the container to serve a static site.
  2. Setup a CNAME record for your domain to point to the CDN URL provided by Cloud Files.
  3. Sign in to CircleCI and link your Pelican blog repository.
  4. Configure the necessary Environment Variables in CircleCI.
  5. Add the circle.yml file to your repository. Commit and push this change, and GitHub will notify CircleCI to process a build.
  6. Review the build in CircleCI to ensure it was published successfully.

That should be all you need to do. Good luck!