Introduction

As part of building my self-hosted Hugo publishing workflow, I wanted something simple:

  • Edit content
  • Commit changes
  • Push to Git
  • Deploy automatically

I didn’t want to manually SSH into the server every time.

So I wrote a small helper script called hillpush.


What hillpush Does

The script automates the full deployment workflow:

  1. Detects the Git repository root
  2. Checks for remote updates
  3. Rebases cleanly if required
  4. Stages and commits changes
  5. Pushes to Git
  6. Triggers the publish script on the web server

In short:

One command → Full deployment.


Example hillpush Script

Sensitive hostnames and usernames have been replaced with placeholders.

#!/bin/bash
set -euo pipefail

TARGET="deployuser@webserver.internal"
REMOTE_REPO="/srv/hugo/site"
PUBLISH_CMD="sudo -u www-data /usr/local/bin/publish-site.sh"

die() { echo "Error: $*" >&2; exit 1; }

REPO_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || true)"
[ -n "${REPO_ROOT}" ] || die "Not in a git repository."

cd "${REPO_ROOT}"

echo "Checking for remote updates..."
git fetch origin

LOCAL=$(git rev-parse @)
REMOTE=$(git rev-parse @{u})

if [ "${LOCAL}" != "${REMOTE}" ]; then
  echo "Rebasing with remote..."
  git pull --rebase --autostash \
    || die "Rebase failed. Resolve conflicts manually."
else
  echo "Already up to date."
fi

git add .

read -r -p "Commit message: " MSG
git commit -m "${MSG}"

git push

echo "Triggering remote publish..."
ssh "${TARGET}" "${PUBLISH_CMD}"

echo "Deployment complete."

The Server-Side Publish Script

On the web server, a separate script handles pulling and rebuilding the site:

#!/bin/bash
set -e

cd /srv/hugo/site

git fetch origin
git reset --hard origin/main

hugo --minify

rsync -av --delete public/ /var/www/html/

This ensures the server:

  • Pulls the latest content
  • Rebuilds the static site
  • Syncs it to the web root

Why This Approach Works

  • No external CI server required
  • No manual SSH sessions
  • Fully version-controlled deployments
  • Clean separation between Git host and public web server
  • Minimal firewall exposure (SSH only where required)

Final Thoughts

For a home lab or personal site, this strikes a great balance:

  • Lightweight
  • Secure
  • Fully automated
  • Easy to understand and maintain

Sometimes a small, well-designed script is all you need instead of a full enterprise CI/CD stack.