Created
January 3, 2018 11:55
-
-
Save DevanR/d3090b7899aa0a443fa1edebd108e713 to your computer and use it in GitHub Desktop.
post-commit git example for remote deployment
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 | |
#ref:https://www.digitalocean.com/community/tutorials/how-to-use-git-hooks-to-automate-development-and-deployment-tasks | |
while read oldrev newrev ref | |
do | |
if [[ $ref =~ .*/master$ ]]; | |
then | |
echo "Master ref received. Deploying master branch to production..." | |
git --work-tree=/var/www/html --git-dir=/home/demo/proj checkout -f | |
else | |
echo "Ref $ref successfully received. Doing nothing: only the master branch may be deployed on this server." | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment