Fork me on GitHub

How This Static Blog Uses Travis-CI

When I started this blog, I was reluctant to put a continuous integration system like Travis-CI in charge of deployment because it seemed like a frivolous use of resources and so I settled for the approach outlined here which worked reasonably well. As my understanding of continuous integration and the possibilities of Travis improved, I changed my mind and decided it would be a good idea to automate this process. I also realised that automating my deployment would allow me to theoretically create or update a post using the GitHub web interface which would automatically get turned into a new post on my blog. This would allow me to use this blog from any web browser! In other words, I wanted a convoluted reimplementation of half of a CMS's functionality.

I found a very helpful blog post that covered most of the details I needed. Let me go through the changes I made.

First off, I use Python 3 wherever possible so I simplified my requirements.txt:

My .travis.yml is different too (I removed unnecessary nesting to make it shorter):

I installed the travis gem, got a GitHub token, and tried to set the token with

travis encrypt GH_TOKEN=LONGTOKENFROMGITHUB --add env.global

but it didn't recognise my repository until I went to my Travis-CI profile, enabled GitHub access, and enabled it to check my repository.

The deploy.sh script was almost the same (change your username):

and that was all the setup I had to do. I then pushed a commit and watched as Pelican and its dependencies were downloaded, my blog posts were regenerated, and my GitHub Pages repo was updated. Seems a bit wasteful, but it was surprisingly easy to get working and it performs admirably.

Comments !

social