Created
April 18, 2013 23:48
-
-
Save 130db/5417091 to your computer and use it in GitHub Desktop.
GIT post-update hook for gitalized web. Update master branch only when it's pushed to repositary
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/sh | |
host="api" | |
domain="example.com" | |
sites="/path/to/your/sites" | |
site="$sites/$host.$domain" | |
cd "$site" || exit | |
unset GIT_DIR | |
update_master() | |
{ | |
echo | |
echo "$host.$domain" | |
echo "Update initialized" | |
echo " * Data wipe out ..." | |
sudo -u www-data rm -rf * | |
echo " * Preparing essential site folders ..." | |
sudo -u www-data mkdir -m 770 -p app/cache | |
sudo -u www-data mkdir -m 770 -p app/logs | |
sudo -u www-data mkdir -p app/config | |
sudo -u www-data mkdir -p root/assets | |
echo " * Site reset & update ..." | |
sudo -u www-data git reset --hard | |
sudo -u www-data git clean -fX | |
sudo -u www-data git pull | |
if [ $? = 0 ]; then | |
echo "Site update finalized!" | |
else | |
echo "Site update FAILED!" | |
fi | |
echo | |
} | |
case " $* " in | |
*' refs/heads/master '*) | |
update_master | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment