diff options
author | Christian Cleberg <hello@cleberg.net> | 2025-01-24 20:26:20 -0600 |
---|---|---|
committer | Christian Cleberg <hello@cleberg.net> | 2025-01-24 20:26:20 -0600 |
commit | dbcec87682afbb2d2bcb3fbeb397a94441a1f8cd (patch) | |
tree | 1667b7286fab00f5a12d0dff04088ba1d0e41ffc /utils | |
parent | 927eefd776aaf6dc89dd6b120303104eb52d5c38 (diff) | |
download | cleberg.net-dbcec87682afbb2d2bcb3fbeb397a94441a1f8cd.tar.gz cleberg.net-dbcec87682afbb2d2bcb3fbeb397a94441a1f8cd.tar.bz2 cleberg.net-dbcec87682afbb2d2bcb3fbeb397a94441a1f8cd.zip |
add more git hooks
Diffstat (limited to 'utils')
-rw-r--r-- | utils/hooks/post-commit | 16 | ||||
-rw-r--r-- | utils/hooks/post-push | 29 | ||||
-rw-r--r-- | utils/hooks/pre-commit | 8 |
3 files changed, 51 insertions, 2 deletions
diff --git a/utils/hooks/post-commit b/utils/hooks/post-commit index d950da6..3064dc6 100644 --- a/utils/hooks/post-commit +++ b/utils/hooks/post-commit @@ -1,4 +1,16 @@ # .git/hooks/post-commit #!/bin/bash -echo "Commit added:" -git show --stat +echo "Environment: Development" + +# Remove previous build +rm -rf .build/* + +# Run publishing script +emacs --script publish.el + +# Minify CSS +minify -o theme/static/styles.min.css theme/static/styles.css + +# Launch development web server +cd .build/ +python3 -m http.server diff --git a/utils/hooks/post-push b/utils/hooks/post-push new file mode 100644 index 0000000..4193037 --- /dev/null +++ b/utils/hooks/post-push @@ -0,0 +1,29 @@ +# .git/hooks/post-push +#!/bin/bash +echo "Environment: Production" + +# Check if publishing via LAN or remotely +printf "Publishing on remote or LAN? [r|l] " + +# Update ubuntu_server variable based on answer +read method +if [[ "$method" =~ ^[Rr]$ ]]; then + ubuntu_server="ubuntu-remote" +elif [[ "$method" =~ ^[Ll]$ ]]; then + ubuntu_server="ubuntu" +else + echo "Invalid input. Assuming LAN (ubuntu)" + ubuntu_server="ubuntu" +fi + +# Remove previous build +rm -rf .build/* + +# Run publishing script +emacs --script publish.el &>/dev/null + +# Minify CSS +minify -o theme/static/styles.min.css theme/static/styles.css + +# Deploy changes +rsync -r --delete-before .build/* $ubuntu_server:/var/www/cleberg.net/ diff --git a/utils/hooks/pre-commit b/utils/hooks/pre-commit new file mode 100644 index 0000000..69883fc --- /dev/null +++ b/utils/hooks/pre-commit @@ -0,0 +1,8 @@ +# .git/hooks/pre-commit +#!/bin/bash +for file in $(git diff --cached --name-only | grep -E '\.org$'); do + if ! grep -q "^#\+TITLE:" "$file"; then + echo "Error: $file is missing a TITLE." + exit 1 + fi +done |