Skip to content

Instantly share code, notes, and snippets.

@abihf
Last active August 29, 2015 14:03
Show Gist options
  • Save abihf/0917349375fad6df9869 to your computer and use it in GitHub Desktop.
Save abihf/0917349375fad6df9869 to your computer and use it in GitHub Desktop.
Git auto deploy on push
#!/bin/sh
read oldrev newrev refname
branch=`echo "$refname" | cut -d/ -f3`
if [ "master" = "$branch" ]
then
deploy_target=`git config --get deploy.target`
if [ -z "$deploy_target" ]; then
echo "Deploy target have not been set";
exit 1
fi
echo " - deploying to $deploy_target"
echo " - updating git from $oldrev to $newrev"
GIT_WORK_TREE="$deploy_target" git checkout -f
if [ -e "$deploy_target/composer.json" ]; then
echo " - runing composer install"
composer --working-dir="$deploy_target" install
fi
echo "Finished Deploy"
else
echo "Push to master to deploying app"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment