How to set up deployment of jekyll websites with gogs + drone

December 13, 2015

I’m not a big fan of wordpress (nor of any CMS in general). The main reason for that is because I like to save every single bit of my resources. The biggest CMS in the world is a huge memory hog. There are some lightweight solutions, such as Anchor, or if you fancy Python, my good ol’ friend QuadPiece has created his own CMS, flask-blog. Although, everything that is dynamically generated can’t be as low on resources as a static site.

About a year and a half ago, I came across GitHub pages, and thus jekyll. I’m telling you, I didn’t really even try to run jekyll at the time, because I was still a newbie to the programming world and I didn’t want to bother trying to set up jekyll via the windows guide. As I think to have already mentioned on this blog somewhere, I think developing on windows if you’re not actually doing .NET development is a pain in the fucking ass. That’s also the case for ruby.

Fast forward to about March of this year, I decided to replace my blog once again, and put it on the front page of my website this time (well, actually a redirect). Grabbed jekyll, a cool theme, changed it a bit, created a placeholder post, and boom, ready to go. Push to the website.

For the first times, I would have manually uploaded the _site folder’s content to the server. After that, I started generating jekyll on the server. Today I decided that had to change. So, I decided to put it under version control, as if it were a GitHub Pages project.

Few months ago I’ve come across gogs, which I think to be the best git system on the world, despite of it lacking many features. Why do I love it so much? Because performance! Yes! Gogs run on very few megabytes of RAM, and doesn’t eat much of your CPU, so due to my performance illness, it was perfect for me.

Shortly later, I’ve installed drone on my server, and integrated it with my gogs instance. It was running amazingly. I do not really use tests on GitHub, because the few times I’ve tried to set up Travis CI I failed, but with drone everything went smoothly, and I love it so far.

Getting back to the blog talk, I put my jekyll blog under version control, just like any 1337 on earth. I then pushed it to a repo on GitHub, and to create a system like the one on GitHub pages, I decided to set up drone to generate the blog each time I pushed something new to it. Here’s the end .drone.yml:

# Check that it builds successfully
  image: grahamc/jekyll
    - jekyll build
# And then push to prod!
      branch: master
    user: $$SSH_USER
    host: $$SSH_HOST
    port: 22
    source: ./\_site/*
    target: $$SSH_FOLDER
    delete: false
    recursive: true

Understanding it is fairly simple: build the website, and then if the branch is master and the build passed, push it to the website via rsync. Easy, isn’t it? So now, I don’t have to do an ssh into my server for updating the blog. Yay git! Yay automation!

© Morgan Bazalgette 2015-2017. Back to main site.