#!/usr/bin/env bash

# https://gohugo.io/hosting-and-deployment/deployment-with-rsync/

set -e

RSYNC_OPTS="-avh --delete"
COMMIT=$(git rev-parse --short HEAD)

sed -i -e "s/^commit\s*=.*$/commit = \"$COMMIT\"/" hugo.toml

rm -rf public/

hugo
tailwindcss -i assets/css/input.css -o static/tailwind.css

rsync $RSYNC_OPTS --dry-run public/ ekzy.is:/var/www/ek

echo
read -p "Continue deploy? [yn] " yn
echo
[ "$yn" == "y" ] && rsync $RSYNC_OPTS public/ ekzy.is:/var/www/ek

git checkout hugo.toml
