Skip to content

Instantly share code, notes, and snippets.

@JanTvrdik
Last active December 10, 2015 01:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JanTvrdik/4357536 to your computer and use it in GitHub Desktop.
Save JanTvrdik/4357536 to your computer and use it in GitHub Desktop.
#!/bin/sh
read oldrev newrev refname
branch=${refname##refs/heads/}
if [[ $branch = "master" || $branch = "stage" ]]
then
echo "Deploying branch $branch..."
targetDir="$PWD/../deployed-$branch"
if [ -d $targetDir ]
then
rm -rf $targetDir/* && \
git archive --format=tar $branch | (cd $targetDir && tar xf -) && \
echo "Done"
else
echo "Error: Directory $targetDir does not exist!"
exit 1
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment