summaryrefslogtreecommitdiff
path: root/content/projects
diff options
context:
space:
mode:
authorGustaf Rydholm <gustaf.rydholm@gmail.com>2022-08-17 00:47:57 +0200
committerGustaf Rydholm <gustaf.rydholm@gmail.com>2022-08-17 00:47:57 +0200
commit86fe708d3d7c6291394953fa663c06f29559688d (patch)
tree0769ccde9f41b9d7906e3f7de774c1b4236b228b /content/projects
parent32c4e59ac59376af6331d883d37f52ecab94df0d (diff)
Add post receive hook draft
Diffstat (limited to 'content/projects')
-rw-r--r--content/projects/hugo-post-receive-hook.md32
1 files changed, 32 insertions, 0 deletions
diff --git a/content/projects/hugo-post-receive-hook.md b/content/projects/hugo-post-receive-hook.md
new file mode 100644
index 0000000..11c9cc5
--- /dev/null
+++ b/content/projects/hugo-post-receive-hook.md
@@ -0,0 +1,32 @@
+---
+title: "Hugo Post Receive Hook"
+date: 2022-08-16T23:50:59+02:00
+draft: true
+tags: ["git", "hugo"]
+---
+
+```sh
+#!/bin/sh
+
+# This hook will update the static website whenever with new commits on each push.
+
+export LC_TYPE="en_US.UTF-8"
+
+www="/var/www"
+src="$(pwd)"
+name=$(basename "$src" '.git')
+web="$www/$name"
+dst="$www/git/$name"
+
+[ ! -d dst ] && mkdir -p "$dst"
+cd "$dst" || exit 1
+
+stagit "$src"
+
+ln -sf log.html index.html
+ln -sf ../style.css style.css
+ln -sf ../logo.png logo.png
+
+git --work-tree="$web" --git-dir="$src" checkout -f
+cd $web && hugo
+```