Created
September 3, 2012 08:11
-
-
Save Asenar/3607809 to your computer and use it in GitHub Desktop.
what's the best way to make this hooks working when the "git fetch" is on an other server ?
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
read oldrev newrev refname | |
branch=${refname#refs/heads/} | |
dir_develop=/home/www/dev.mywebsite.com | |
dir_master=/home/www/mywebsite.com | |
[email protected] | |
if (test "$branch" = "develop") then | |
cd $dir_develop | |
unset GIT_DIR | |
git fetch origin | |
git reset --hard origin/master | |
#chmod g+w * -R | |
res="$?" | |
if (test ! -z "$res") then | |
echo "$dir_develop has been updated from $oldrev to $newrev (refname=$refname)"| mail -s "[DEPLOY OK] branch $branch " $mail | |
else | |
echo "error when git pull origin $branch in '$dir_develop'. (error=$res). When update from $oldrev to $newrev (refname=$refname)"| mail -s "[DEPLOY ERROR] branch $branch " $mail | |
fi | |
else | |
if (test "$branch" = "master") then | |
#export GIT_WORK_TREE=$dir_develop | |
cd $dir_master | |
unset GIT_DIR | |
git fetch origin | |
git reset --hard origin/master | |
#git checkout -f master | |
#cd $dir_master | |
#unset GIT_DIR | |
#git pull origin $branch | |
#chmod g+w * -R | |
res="$?" | |
if (test ! -z "$res") then | |
echo "$dir_master has been updated from $oldrev to $newrev (refname=$refname)"| mail -s "[DEPLOY OK] branch $branch " $mail | |
else | |
echo "error when git pull origin $branch in '$dir_master'. (error=$res). When update from $oldrev to $newrev (refname=$refname)"| mail -s "[DEPLOY ERROR] branch $branch " $mail | |
fi | |
else | |
echo "ref != develop, nothing has been done :) "| mail -s "[DEV] /dev/null :p" $mail | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment