Project

General

Profile

Actions

Task #167

closed

Task #174: Automatically deploy blog on each fossil commit

Fossil: setup after-receive hooks to deploy nawan.my.id

Added by Nawan 24 days ago. Updated 13 days ago.

Status:
Declined
Priority:
Normal
Assignee:
Category:
VCS/Forge
Target version:
Start date:
Due date:
% Done:

100%

Estimated time:
0:15 h

Description

#!/bin/bash

# --- CONFIGURATION ---

# Path to the Fossil repository file on the server
FOSSIL_REPO="/path/to/mywebsite.fossil"

# The temporary directory to create the working copy for Hugo build
# This must be outside the web root.
WORK_DIR="/tmp/hugo_build_temp"

# The final destination for the static site files on the web server (via rsync)
# This is usually the document root (e.g., public_html)
# Replace user@host:path_to_webroot with your actual details
RSYNC_DEST="user@host:/var/www/myhugo-site-public"

# --- DEPLOYMENT LOGIC ---

# Ensure we operate in a clean environment
mkdir -p "$WORK_DIR"
cd "$WORK_DIR" || exit 1

# 1. Clean up any previous checkout (important for a fresh build)
rm -rf "$WORK_DIR"/*

# 2. Check out the latest committed version from the repository
# We use 'fossil open' to establish a checkout connection
# The '--once' flag tells it to only run the checkout and exit (not start a UI)
fossil open "$FOSSIL_REPO"

# 3. Build the Hugo site
# The 'hugo' command builds the site into the 'public/' subdirectory of the
# current working directory (which is $WORK_DIR)
# Use '--cleanDestinationDir' if you want a complete wipe before building
echo "Building Hugo site..."
hugo

# Check if the Hugo build was successful
if [ $? -ne 0 ]; then
    echo "Hugo build failed! Aborting deployment."
    exit 1
fi

# 4. Deploy the static files using rsync over SSH
# -a: archive mode (preserves permissions, ownership, etc.)
# -v: verbose
# -z: compress file data during transfer
# --delete: delete extra files from the destination that are not present in the source
echo "Deploying with rsync..."
rsync -avz --delete public/ "$RSYNC_DEST"

# 5. Clean up the temporary checkout directory after successful deployment
cd /
fossil close --force || true # Close the checkout connection
rm -rf "$WORK_DIR"
echo "Deployment complete."

Related issues 2 (0 open2 closed)

Blocked by Infrastruktur - Task #186: Enable WAL mode for www.fossil databaseDeclined

Actions
Copied to Infrastruktur - Task #187: Fossil: setup before-commit hooks to deploy nawan.my.idResolvedNawan

Actions
Actions #1

Updated by Nawan 22 days ago

  • Blocked by Task #166: Install fossil from debian repo added
Actions #2

Updated by Nawan 22 days ago

  • Blocked by deleted (Task #166: Install fossil from debian repo)
Actions #3

Updated by Nawan 22 days ago

  • Follows Task #166: Install fossil from debian repo added
Actions #4

Updated by Nawan 22 days ago

  • Follows deleted (Task #166: Install fossil from debian repo)
Actions #5

Updated by Nawan 22 days ago

  • Blocked by Task #166: Install fossil from debian repo added
Actions #6

Updated by Nawan 22 days ago

  • Assignee set to Nawan
Actions #7

Updated by Nawan 22 days ago

  • Parent task set to #164
Actions #8

Updated by Nawan 22 days ago

  • Blocked by deleted (Task #166: Install fossil from debian repo)
Actions #9

Updated by Nawan 22 days ago

  • Parent task deleted (#164)
Actions #10

Updated by Nawan 20 days ago

  • Parent task set to #174
Actions #11

Updated by Nawan 18 days ago

  • Target version set to Q4 2025
Actions #12

Updated by Nawan 18 days ago

  • Blocks Idea #165: Artikel ulasan Nimona added
  • Blocks Idea #3: Artikel tentang Obsidian dan vendor lock-in added
  • Blocks Idea #119: Artikel tentang suka duka menggunakan Redmine added
Actions #13

Updated by Nawan 18 days ago

  • Blocks deleted (Idea #3: Artikel tentang Obsidian dan vendor lock-in)
Actions #14

Updated by Nawan 18 days ago

  • Blocks deleted (Idea #165: Artikel ulasan Nimona)
Actions #15

Updated by Nawan 18 days ago

  • Blocks deleted (Idea #119: Artikel tentang suka duka menggunakan Redmine)
Actions #16

Updated by Nawan 18 days ago

  • Estimated time set to 0:15 h
Actions #17

Updated by Nawan 18 days ago

  • Start date set to 2025-12-13
Actions #18

Updated by Nawan 18 days ago

  • Estimated time deleted (0:15 h)
Actions #19

Updated by Nawan 18 days ago

  • Estimated time set to 0:15 h
Actions #20

Updated by Nawan 18 days ago

  • Start date changed from 2025-12-13 to 2025-12-15
Actions #21

Updated by Nawan 18 days ago

  • Start date deleted (2025-12-15)
Actions #22

Updated by Nawan 15 days ago

  • Description updated (diff)
  • Status changed from New to In Progress
  • % Done changed from 0 to 30
Actions #23

Updated by Nawan 13 days ago

  • % Done changed from 30 to 60

Memutuskan untuk mengimplementasikan after-receive hook di repositori lokal alih-alih di server.

Actions #24

Updated by Nawan 13 days ago

Nawan wrote in #note-23:

Memutuskan untuk mengimplementasikan after-receive hook di repositori lokal alih-alih di server.

Ternyata lebih mudah jika di server karena after-receive hook tidak berjalan setelah mengkomit perubahan lokal dan dalam banyak kasus perlu dibantu dengan cron.

Actions #25

Updated by Nawan 13 days ago

  • Blocked by Task #186: Enable WAL mode for www.fossil database added
Actions #26

Updated by Nawan 13 days ago ยท Edited

Because of the way I set up Fossil (#170), the after-receive hook script written in Bash will not work unless Bash, Hugo, and everything else necessary to run are mounted in the chroot directory. This is because, in my current configuration, Fossil automatically drops into the chroot jail. It may be worth considering using the before-commit hook instead, which I already use to test whether it can build.

Actions #27

Updated by Nawan 13 days ago

  • Copied to Task #187: Fossil: setup before-commit hooks to deploy nawan.my.id added
Actions #28

Updated by Nawan 13 days ago

  • Status changed from In Progress to Declined
  • % Done changed from 60 to 100

I decided not to implement this task in favour of #187 because I think it's too complex than with before-commit hooks on local repository.

Actions

Also available in: Atom PDF