Script for deploying changes in Hugo files - Fri, Dec 30, 2022
After building the new static site, the files from the public directory will be synched to my server
sudo nano /usr/local/bin/deploy_hugo
sudo chmod 755 /usr/local/bin/deploy_hugo
/home/ht_new/Dokumente/Projekte/Hugo/home/der-wenth
#!/bin/bash
PORT=[Port]
KEYFILE=[Path]
USER=[User]
HOST=[Host]
for var in "$@"
do
if [ "$var" == "blog" ]
then
echo "$var wird deployed"
TARGET=home/blog
EXCLUDE=""
cd $HOME/Dokumente/Projekte/Hugo/home/der-wenth
elif [ "$var" == "home" ]
then
echo "$var wird deployed"
TARGET=home
EXCLUDE="--exclude blog/"
cd $HOME/Dokumente/Projekte/Hugo/blog
else
echo "$var ist ein ungültige Eingabe"
exit 1
fi
hugo && rsync -e "ssh -i $KEYFILE -p $PORT" -avz $EXCLUDE --delete public/ ${USER}@${HOST}:${TARGET}
cd -
done
deploy_hugo blog