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 +