From c8cb765f24649745d5b0eec9f96e0592c6168b10 Mon Sep 17 00:00:00 2001 From: Dominic Reich Date: Sat, 8 Apr 2023 21:07:50 +0200 Subject: [PATCH] add git hooks into repo also set "hooksPath = .githooks" and maybe "excludesfile = .gitignore" in `.git/config` --- .githooks/pre-push | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 .githooks/pre-push diff --git a/.githooks/pre-push b/.githooks/pre-push new file mode 100755 index 0000000..12a39a4 --- /dev/null +++ b/.githooks/pre-push @@ -0,0 +1,31 @@ +#!/bin/bash +# create static files with hugo and upload them with rsync +# to my webserver +# created: 2023-03-26T23:27:11+0200 + +echo -n "creating website..." + +ret="$(hugo --gc --minify)" + +# if [ -n "$(echo $ret | grep Total)" ] ; then +if [ "$?" -eq "0" ] ; then + echo " Success!" +else + echo " *** FAILED ***" + echo "Could not create static files (hugo). Aborting..." + # exit with 1, so the update does not proceed, so we will know + exit 1 +fi + +echo -n "rsyncing files to server..." + +ret="$(rsync -avhzP --stats --del public/ bor:/var/www/sites/oe7drt/)" + +if [ "$?" -eq "0" ] ; then + echo "Success!" +else + echo " *** FAILED ***" + echo "Could not sync files to webserver (rsync). Aborting..." + exit 1 +fi +