Comfortably deploy your static webpage to Fastmail

I use Fastmail for all my webmail needs and was quite pleased when I found out that they also support basic static webpage hosting including automatic SSL certificate creation via letsencrypt. It is certainly far less comfortable than other solutions out there, as it doesn't provide automated content building and deployment. But this shortcoming is easy enough to fix and why not use what you already have. So I threw together a small script for updating my blog using lftp:

#!/bin/bash
HOST="ftp.fastmail.com"
USER="${FASTMAIL_USERNAME}"
PASS="${FASTMAIL_APP_PASSWORD}"
TARGETFOLDER="${FASTMAIL_FOLDER}"
SOURCEFOLDER="."

lftp -f "
set ftp:ssl-force true
set ftp:ssl-protect-data true
open $HOST
user $USER $PASS
lcd site
mirror --reverse --delete --verbose $SOURCEFOLDER $TARGETFOLDER
bye
"

(Please note that the ssl-* commands are really important here as you are otherwise pushing all your data without encryption).

So after writing a new post and building it with pilea (hint, hint) all I need to do is run that shell script and everything else happens automatically. Running this script looks like this:

./sync.sh
source: Is a directory
Removing old file `archive.html'
Transferring file `archive.html'
Removing old file `atom.xml'
Transferring file `atom.xml'
Removing old file `index.html'
Transferring file `index.html'
Removing old file `rss.xml'
Transferring file `rss.xml'
Removing old file `pages/datenschutz.html'
Transferring file `pages/datenschutz.html'
...

This script is now running as part of a Drone CI Pipeline I have set up on a private instance running on my NUC and automatically deploys this webpage whenever I push a change to master.

kind: pipeline
type: docker
name: default

steps:
- name: Build
  image: pilea
  commands:
  - pilea build

- name: Deploy
  image: ubuntu
  commands:
    - apt-get update && apt-get install --yes lftp
    - ./sync.sh
  environment:
    FASTMAIL_USERNAME:
      from_secret: FASTMAIL_USER
    FASTMAIL_PASSWORD:
      from_secret: FASTMAIL_PASSWORD
    FASTMAIL_FOLDER:
      from_secret: FASTMAIL_FOLDER