Skip to content

Instantly share code, notes, and snippets.

@mkhazov
Created July 10, 2015 23:25
Show Gist options
  • Save mkhazov/b91d69fc3f077bcf5c8d to your computer and use it in GitHub Desktop.
Save mkhazov/b91d69fc3f077bcf5c8d to your computer and use it in GitHub Desktop.
Automate Deployment with git post-receive hook
#!/bin/bash
while read oldrev newrev ref
do
if [[ $ref =~ .*/master$ ]];
then
echo "Master ref received. Deploying master branch to production..."
git --work-tree=/path/to/production --git-dir=/path/to/git 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