From c48ca0ca40ed9ac009d7f84ce213ef5c69536ca7 Mon Sep 17 00:00:00 2001 From: alex Date: Sun, 1 Feb 2026 21:47:23 +0100 Subject: Migrate blog Turns into a static site generator. All Gemini files with links have been rewritten to be relative. Closes: #731 Closes: #372 Closes: #28 --- blog/post-receive | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 blog/post-receive (limited to 'blog/post-receive') diff --git a/blog/post-receive b/blog/post-receive new file mode 100755 index 00000000..d5f26676 --- /dev/null +++ b/blog/post-receive @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 +import os +import pathlib +import subprocess +import sys +import tempfile + + +target_ref = "refs/heads/master" +pushed_commit = None +uv = pathlib.Path.home() / ".local" / "bin" / "uv" +dest = pathlib.Path.home() / "public_html" + +refs = sys.stdin.readlines() + +for ref in refs: + _from, to, ref = ref.split() + if ref == target_ref: + pushed_commit = to + +if not pushed_commit: + print("Not pushing to {target_ref}, move on") + sys.exit(0) + +print(f"Building {pushed_commit}", flush=True) + +with tempfile.TemporaryDirectory() as tempdir: + tempdir = pathlib.Path(tempdir) + repo = tempdir / "repo" + subprocess.run(["git", "worktree", "add", repo, pushed_commit], check=True) + blog = repo / "blog" + os.chdir(blog) + built = tempdir / "built" + subprocess.run([uv, "run", "blog", "build", blog, built], check=True) + subprocess.run(["rsync", "-r", "--delete-after", f"{built}/", f"{dest}/"], check=True) -- cgit v1.2.3