#!/bin/bash TARGET="/home/bitnami/apps/redmine/htdocs/public/themes/Ossig" GIT_DIR="/repo/ossig-theme.git" BRANCH="master" RESTART_APACHE="" # shellcheck disable=SC2034 # shellcheck disable=SC2162 while read oldrev newrev ref; do if [ "$ref" = "refs/heads/$BRANCH" ]; then echo "Ref $ref received. Deploying ${BRANCH} branch to production..." git --work-tree=$TARGET --git-dir=$GIT_DIR checkout -f $BRANCH if [[ -n $RESTART_APACHE ]]; then echo "Restarting Apache Webserver" sudo "$HOME/stack/ctlscript.sh" restart apache >>/dev/null 2>&1 fi else echo "Ref $ref received. Doing nothing: only the ${BRANCH} branch may be deployed on this server." fi done