Skip to content

Instantly share code, notes, and snippets.

@DevanR
Created January 3, 2018 11:55
Show Gist options
  • Save DevanR/d3090b7899aa0a443fa1edebd108e713 to your computer and use it in GitHub Desktop.
Save DevanR/d3090b7899aa0a443fa1edebd108e713 to your computer and use it in GitHub Desktop.
post-commit git example for remote deployment
#!/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