#!/bin/bash set -e install_dir=/var/www/vhosts/ log_file=/var/log/github/update.log branch=main # If the following commands fail, it is too late to abort the push. # Try to avoid doing things that might fail! echo "$(date '+%F %T %z'): $branch: post-receive started" >> $log_file exec 3>&1 exec &> >(tee -a $log_file) # Install into `install_dir` echo "* Installing new server code..." GIT_WORK_TREE=$install_dir git checkout --force "$branch" 2>> $log_file # Restart the uwsgi server echo "* Reloading uwsgi server..." # Could do 'sudo symstemctl restart uwsgi.service' but floods logs sudo touch /etc/uwsgi.d/waveform_annotation.ini echo "$(date '+%F %T %z'): $branch: post-receive finished" >> $log_file echo >> $log_file