2017-06-05 15:31:47 +02:00
|
|
|
#!/usr/bin/env bash
|
2017-06-05 18:53:32 +02:00
|
|
|
# post-receive hook for automated deployment
|
2017-06-05 15:31:47 +02:00
|
|
|
|
|
|
|
GIT_REPO=$HOME/vbrandl.git
|
|
|
|
WORKING_DIRECTORY=$HOME/vbrandl-working
|
|
|
|
PUBLIC_WWW="/var/www/vbrandl.net"
|
|
|
|
BACKUP_WWW=$HOME/blog_backup
|
|
|
|
MY_DOMAIN=www.vbrandl.net
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2018-07-16 12:23:00 +02:00
|
|
|
echo Deleting old working directory...
|
2017-06-05 15:31:47 +02:00
|
|
|
rm -rf $WORKING_DIRECTORY
|
2018-07-16 12:23:00 +02:00
|
|
|
echo Creating backup...
|
2017-06-05 15:31:47 +02:00
|
|
|
rsync -aqz ${PUBLIC_WWW}/ $BACKUP_WWW
|
2018-07-16 12:23:00 +02:00
|
|
|
trap "echo 'A problem occurred. Reverting to backup.'; rsync -aqz --del $BACKUP_WWW/ $PUBLIC_WWW; rm -rf
|
|
|
|
$WORKING_DIRECTORY" EXIT
|
2017-06-05 15:31:47 +02:00
|
|
|
|
2018-07-16 12:23:00 +02:00
|
|
|
echo Cloning into working directory...
|
2017-06-05 15:35:26 +02:00
|
|
|
git clone --recursive $GIT_REPO $WORKING_DIRECTORY
|
2018-07-16 12:23:00 +02:00
|
|
|
echo Deleting old version...
|
2017-06-05 15:31:47 +02:00
|
|
|
rm -rf $PUBLIC_WWW/*
|
2018-07-16 12:23:00 +02:00
|
|
|
echo Generating HTML...
|
2017-06-05 15:36:28 +02:00
|
|
|
$HOME/.local/bin/hugo -s $WORKING_DIRECTORY -d ${PUBLIC_WWW} -b "https://${MY_DOMAIN}"
|
2017-06-05 18:49:57 +02:00
|
|
|
# ahead of time compression
|
2018-07-16 12:23:00 +02:00
|
|
|
echo Compressing files ahead of time...
|
|
|
|
make -C $PUBLIC_WWW -f $WORKING_DIRECTORY/Makefile
|
|
|
|
echo Deleting working directory...
|
2017-06-05 15:31:47 +02:00
|
|
|
rm -rf $WORKING_DIRECTORY
|
|
|
|
trap - EXIT
|