2023-04-08 22:40:14 +02:00
#!/usr/bin/env bash
2023-04-08 21:07:50 +02:00
# create static files with hugo and upload them with rsync
# to my webserver
# created: 2023-03-26T23:27:11+0200
2023-04-08 22:55:58 +02:00
clean_up () {
echo -n ">>> Removing output files..."
rm -rf public
if [ "$?" -eq "0" ]; then
echo " Success!"
else
echo " *** FAILED ***"
echo "Could not delete output files (public). Aborting..."
exit 1
fi
}
echo -n ">>> Creating static files with `hugo version | awk '{ print $1,$2 }'`..."
2023-04-08 21:07:50 +02:00
2023-11-19 13:29:17 +01:00
ret="$(hugo --gc --minify --cleanDestinationDir --printPathWarnings --logLevel warn)"
2023-04-08 21:07:50 +02:00
# if [ -n "$(echo $ret | grep Total)" ] ; then
if [ "$?" -eq "0" ] ; then
echo " Success!"
else
echo " *** FAILED ***"
echo "Could not create static files (hugo). Aborting..."
2023-04-08 22:55:58 +02:00
clean_up
2023-04-08 21:07:50 +02:00
# exit with 1, so the update does not proceed, so we will know
exit 1
fi
2023-12-31 13:10:33 +01:00
# git lfs
echo -n ">>> Check for git-lfs..."
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting .git/hooks/pre-push.\n"; exit 2; }
git lfs pre-push "$@"
echo " Done!"
2023-04-08 22:55:58 +02:00
echo -n ">>> Pushing files to server..."
2023-04-08 21:07:50 +02:00
2023-08-12 08:57:05 +02:00
ret="$(rsync --no-motd -acvhz --stats --del public/ bor:/var/www/sites/oe7drt/ > /dev/null 2>&1)"
2023-04-08 21:07:50 +02:00
if [ "$?" -eq "0" ] ; then
2023-04-08 22:55:58 +02:00
echo " Success!"
2023-04-08 21:07:50 +02:00
else
echo " *** FAILED ***"
echo "Could not sync files to webserver (rsync). Aborting..."
2023-04-08 22:55:58 +02:00
clean_up
2023-04-08 21:07:50 +02:00
exit 1
fi
2023-04-08 22:55:58 +02:00
clean_up