Build and Deploy HUGO using DroneCI

After playing around with Hugo for a bit I realized I’m way too lazy to build, check and deploy my website everytime I change a small detail. I’m already using Gitea and DroneCI for a few other projects - so choosing those tools was a nobrainer.

Hugo + Gitea + DroneCI

After setting up DroneCI+Gitea and a new repository I just had to create a new .drone.yml file to get started. Thanks to the many included pipeline Plugins building hugo and deploying via rsync was pretty straight forward.

Here’s what my .drone.yml looks like this:

---
kind: pipeline
name: default

steps:
- name: Clone submodules
  image: alpine/git
  commands:
  - git submodule update --init --recursive

- name: Build
  image: plugins/hugo
  settings:
    hugo_version: 0.134.3
    extended: true
  commands:
    - apk add libc6-compat libstdc++ gcompat
    - ln -s /lib/libc.so.6 /usr/lib/libresolv.so.2
    - /bin/drone-hugo

- name: Deploy
  image: drillster/drone-rsync
  settings:
    hosts:
      - <TARGET_HOST>
    user: root
    key:
      from_secret: <MY_SECRET_KEY>
    source: ./public/
    target: <TARGET_DIRECTORY on TARGET_HOST>
    recursive: true
    delete: true

Everytime I commit and push changes to my git repository, this website is built automatically and synced to the public directory of my webserver. The secret (ssh private key) the deploy the website is stored in DroneCI aswell.

Adding new content to my blog is now pretty fast, efficient and reliable.

edit 09-2024: Had to add a few apk-packages and a symlink to make hugo work again with a version > 115