Skip to content

Instantly share code, notes, and snippets.

@edwinpgm
Last active August 30, 2017 16:20
Show Gist options
  • Save edwinpgm/9aac5c47ae15b51f9688c0961e6e97b7 to your computer and use it in GitHub Desktop.
Save edwinpgm/9aac5c47ae15b51f9688c0961e6e97b7 to your computer and use it in GitHub Desktop.
Git hooks to automate deployment tasks
# 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
@edwinpgm
Copy link
Author

--> /opt/client
--> /opt/api

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment