No Hassle Blog Automation Redux

No more Jenkins.

Due to the difficulty in maintaining a full Jenkins instance, I have revisited the blog automation issue and have replaced Jenkins with Drone. Making use of a tool like Drone greatly simplifies the setup process and lowers the barrier of entry for this type of project.

Requirements

There are a few requirements for this setup:

  • Rackspace Cloud Account
  • Existing Pelican Blog
  • GitHub Account
  • Linux Administration Knowledge

You should also read my original article.

Drone

There are two options here for using Drone.

Drone.io

Register a free account at Drone.io.

Using Drone.io’s free service has some disadvantages. You can’t specify custom docker images for your testing. There also isn’t a direct method to publish your blog output to Rackspace Cloud Files. I recommend you make use of the second option and run your own instance.

Open Source Drone

Run your own Drone instance using my Ansible Drone Role. Some key points of this setup include:

  • The use of the undocumented $DRONE_BUILD_DIR environmental variable. This is the working directory where the git checkout is placed.
  • The use of parameters {{rax_username}} and {{rax_apikey}}. You define these in your Drone instance settings. This feature allows you to keep secrets secure.
  • Make sure the container you define is published to the CDN, and is enabled to serve as a Web Site. You can now enable this through the Rackspace Cloud Control Panel.

Documentation and install instructions are available on Drone’s GitHub Page. You can follow these instructions if you are unfamiliar with Ansible.

Docker

I maintain a Trusted Build in the Docker Registry for Pelican. The image name is linuturk/pelican. We will be using this image to simplify our .drone.yml.

Remember, if you are using the free account provided by Drone.io, you won’t be able to use this image.

.drone.yml

This file is used by the open source Drone.io to define the build process. You can find my current .drone.yml file in my repository.

image: linuturk/pelican
script:
  - make -C $DRONE_BUILD_DIR html
publish:
  swift:
    username: {{rax_username}}
    password: {{rax_apikey}}
    auth_url: https://identity.api.rackspacecloud.com/v2.0
    region: ORD
    container: www.onitato.com
    source: $DRONE_BUILD_DIR/output
    branch: master

There are three main sections to this file:

  • image: This defines the Docker image to use for the build.
  • script: This defines the commands to run for the build process.
  • publish: This is set to publish the contents of the output directory to Rackspace Cloud Files.

The only options you should have to change for your deployment are region and container.

Setup

Here is a high level overview of the setup steps:

  1. Create a container in Cloud Files, and make sure you configure the Website Settings and ensure it is published to the CDN.
  2. Setup a DNS record for your domain to point to the CDN URL provided by Cloud Files.
  3. Install and configure an instance of the open source Drone project.
  4. Register your Drone instance with GitHub. Here’s a quick guide.
  5. Use the Drone web interface to add your repository to Drone. This process also automatically creates the necessary web hooks in GitHub.
  6. Configure the necessary Parameters for the swift publish option.
  7. Add the .drone.yml file to your repository. Commit and push this change, and GitHub will notify Drone to process a build.
  8. Review the build in the Drone web interface to ensure it was published successfully.

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