Last active
August 30, 2017 16:20
-
-
Save edwinpgm/9aac5c47ae15b51f9688c0961e6e97b7 to your computer and use it in GitHub Desktop.
Git hooks to automate deployment tasks
This file contains hidden or 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
# https://www.digitalocean.com/community/tutorials/how-to-use-git-hooks-to-automate-development-and-deployment-tasks | |
#!/bin/bash | |
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/git/repositories/repository.git checkout -f | |
else | |
echo "Ref $ref successfully received. Doing nothing: only the master branch may be deployed on this server." | |
fi | |
done | |
# Change permissions | |
chmod +x hooks/post-receive | |
# Change Permissions | |
chmod XXX /var/www/html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
--> /opt/client
--> /opt/api