Last active
May 15, 2020 18:18
-
-
Save NicmeisteR/d023c66f2f6c39cab61812b8734a722e to your computer and use it in GitHub Desktop.
Git Hooks File
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Location of our bare repository. | |
GIT_DIR="/var/www/halosouthafrica.co.za/repo" | |
# Where we want to copy our code. | |
TARGET="/var/www/halosouthafrica.co.za/temp" | |
while read oldrev newrev ref | |
do | |
# Neat trick to get the branch name of the reference just pushed: | |
BRANCH=$(git rev-parse --symbolic --abbrev-ref $ref) | |
if [[ $BRANCH == "refactoring" ]]; | |
then | |
# Send a nice message to the machine pushing to this remote repository. | |
echo "Push received! Deploying branch: ${BRANCH}..." | |
rm -R /var/www/halosouthafrica.co.za/html/* | |
# "Deploy" the branch we just pushed to a specific directory. | |
git --work-tree=$TARGET --git-dir=$GIT_DIR checkout -f $BRANCH | |
cp -R /var/www/halosouthafrica.co.za/temp/dist/HaloSA/* /var/www/halosouthafrica.co.za/html | |
else | |
echo "Not master branch. Skipping." | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment