Commit af386793e7

af386793e701976293c05fbdd409470cb324915a

parent: 47daf032cc

Unsigned

cmc <hello@cleberg.net> · 2025-01-25 02:26 UTC

add more git hooks

Layout: unified · split

utils/hooks/post-commit +14 −2
@@ -1,4 +1,16 @@
11# .git/hooks/post-commit
22#!/bin/bash
3echo "Commit added:"
4git show --stat
3echo "Environment: Development"
4
5# Remove previous build
6rm -rf .build/*
7
8# Run publishing script
9emacs --script publish.el
10
11# Minify CSS
12minify -o theme/static/styles.min.css theme/static/styles.css
13
14# Launch development web server
15cd .build/
16python3 -m http.server
utils/hooks/post-push added +29
@@ -0,0 +1,29 @@
1# .git/hooks/post-push
2#!/bin/bash
3echo "Environment: Production"
4
5# Check if publishing via LAN or remotely
6printf "Publishing on remote or LAN? [r|l] "
7
8# Update ubuntu_server variable based on answer
9read method
10if [[ "$method" =~ ^[Rr]$ ]]; then
11 ubuntu_server="ubuntu-remote"
12elif [[ "$method" =~ ^[Ll]$ ]]; then
13 ubuntu_server="ubuntu"
14else
15 echo "Invalid input. Assuming LAN (ubuntu)"
16 ubuntu_server="ubuntu"
17fi
18
19# Remove previous build
20rm -rf .build/*
21
22# Run publishing script
23emacs --script publish.el &>/dev/null
24
25# Minify CSS
26minify -o theme/static/styles.min.css theme/static/styles.css
27
28# Deploy changes
29rsync -r --delete-before .build/* $ubuntu_server:/var/www/cleberg.net/
utils/hooks/pre-commit added +8
@@ -0,0 +1,8 @@
1# .git/hooks/pre-commit
2#!/bin/bash
3for file in $(git diff --cached --name-only | grep -E '\.org$'); do
4 if ! grep -q "^#\+TITLE:" "$file"; then
5 echo "Error: $file is missing a TITLE."
6 exit 1
7 fi
8done