Skip to content

Instantly share code, notes, and snippets.

@abdel
Last active October 19, 2015 21:09
Show Gist options
  • Save abdel/bf8fbcfdc8a6f290dadb to your computer and use it in GitHub Desktop.
Save abdel/bf8fbcfdc8a6f290dadb to your computer and use it in GitHub Desktop.
Automatic Git Deployment
#!/bin/bash
# Hook Setup
source $(dirname $0)/hook-setup
while read oldrev newrev ref
do
if [[ $ref =~ .*/master ]];
then
echo "Ref $ref successfully received. Deploying to $PROJECT_DIR..."
git --work-tree=/var/www/$PROJECT --git-dir=/home/git/repositories/$USERNAME/$REPOSITORY checkout -f
else
echo "Ref $ref successfully received."
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment