openpunk-ansible/roles/blog/templates/updateBlog

32 lines
843 B
Plaintext
Raw Normal View History

#!/bin/bash
cd /var/www/{{ domain }}
PUBLIC_DIR=public
TOR_DIR=tor
buildBlog () {
hugo --cleanDestinationDir --minify -d $PUBLIC_DIR -b https://{{ domain }}
hugo --cleanDestinationDir --minify -d $TOR_DIR -b {{ onionDomain }}
}
git fetch origin
UPSTREAM=${1:-'@{u}'}
LOCAL=$(git rev-parse @)
REMOTE=$(git rev-parse "$UPSTREAM")
BASE=$(git merge-base @ "$UPSTREAM")
if [ $LOCAL = $REMOTE ]; then
2023-01-17 23:52:47 +00:00
# this string is hardcoded && checked by the 'Build blog' task
# to check for changes (changed_when)
echo "up to date"
elif [ $LOCAL = $BASE ]; then
2023-02-02 00:01:52 +00:00
# there are changes to reset to so we need to rebuild
2023-01-17 23:52:47 +00:00
echo "missing changes !!"
git reset --hard origin/main
buildBlog
2023-01-17 23:52:47 +00:00
fi
if [ ! -d "$PUBLIC_DIR" ] || [ ! -d "$TOR_DIR" ]; then
# probably first time setup
echo "missing directories !!"
buildBlog
fi