Skip to content

Instantly share code, notes, and snippets.

@jrlangford
Created August 4, 2016 16:21
Show Gist options
  • Save jrlangford/7b40a4f7350a57940b0124a2bd93c9f5 to your computer and use it in GitHub Desktop.
Save jrlangford/7b40a4f7350a57940b0124a2bd93c9f5 to your computer and use it in GitHub Desktop.
Git production repo post-receive hook to automatically deploy code.
#!/bin/bash
while read oldrev newrev ref
do
if [[ $ref =~ .*/master$ ]];
then
echo "Master ref received, deploying master branch to production"
git --work-tree=<Target dir from which static content will be served> --git-dir=<source bare repo dir> checkout -f && \
echo "Success, master branch deployed!!" || \
echo "Error while deploying master branch"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment