As of Dec 2021, this is now outdated. I am no longer using Dendron, nor nomad to deploy the site. I’ll have a follow up shortly.

This expands on the DroneCI -> Nomad pipeline I examined earlier

I explained why I use Dendron, today I will show how. The glue that binds Dendron, Quantified Self reports, and Hugo is DroneCI.

The CI build runs every night and immediately when a commit is made to the Hugo site.

I wrote a custom Pod for exporting notes. It’s similar to the built-in markdown pod, but includes frontmatter and renders a hierarchical structure which makes Hugo happy.

The server completes these build steps:

  1. Clone the required build repos from Github / Gitea:
    1. Hugo site workspace
    2. Hugo site theme
    3. Dendron workspace and notes
    4. Dendron <-> Hugo export pod
    5. Nomad config files
  2. Once the files are in order, we install dendron-cli and link the hugo-pod in an node container
  3. Apply the included patch that skips validation of the pod
  4. Run the export pod, creating a well formed /garden/ subdirectory in Hugo’s content folder
  5. Build the Hugo site
  6. Build the final Docker image with the new public directory
  7. Publish the final Docker image
  8. Send a redeploy command to Nomad using the config cloned in step 1.
  9. Prune old Docker images from our registry

Done! Simple, no? 😆

The complexity stems from the sources being so scattered (Dendron, Hugo, Nomad…). Obviously this isn’t practical for casual note writing. But in my head, if it’s worth doing it’s also worth overdoing.

This is the full .drone.yml spec:

kind: pipeline
type: docker
name: default

    image: plugins/git
    recursive: true

  - name: "Clone hugo theme"
    image: alpine/git
      - sed -ir 's$:$/$' .gitmodules
      - sed -ir 's$git@ssh.$https://$g' .gitmodules
      - git submodule update --recursive --init

  - name: "Clone Dendron notes and export pod"
    image: alpine/git
      - git clone
      - git clone notes
      - cd notes
      - git clone garden

  - name: "Export Dendron notes"
    image: node:current-alpine3.11
      - npm install -g @dendronhq/dendron-cli
      - cd hugo-podand
      - npm install
      # Skip validation error "data must NOT have additional properties"
      - patch node_modules/@dendronhq/pods-core/lib/utils.js < utils.js.patch
      - npm link
      - cd ../notes/
      - npm link hugo-pod
      - dendron-cli exportPod --wsRoot ./ --podId hugo --podPkg hugo-pod --podSource custom --config "fname=dendron,vaultName=vault,dest=../content,includeStubs=true"

  - name: "Build site with hugo"
    image: klakegg/hugo:ext-alpine
      - hugo

  - name: publish
    image: plugins/docker
        - latest
      username: casey
        from_secret: registry_password

  - name: clone deployment dotfiles
    image: alpine/git
      - git clone -b abathur

  - name: redeploy nomad
    image: multani/nomad
      - nomad run -address= -var=image_id=${DRONE_BUILD_NUMBER} dotfiles/nomad/webserver/

  - name: prune images
    image: anoxis/registry-cli:latest
      - / -l casey:$PASSWORD -r -i garden-quinncasey --delete --num 10 --keep-tags "stable" "latest"
        from_secret: registry_password