summaryrefslogtreecommitdiff
path: root/content/projects/hugo-post-receive-hook.md
blob: 11c9cc5b47af7ba48e30b989087b7ce818d826bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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
```