Skip to content

Instantly share code, notes, and snippets.

@gbluma
Last active January 4, 2016 01:39
Show Gist options
  • Save gbluma/8550264 to your computer and use it in GitHub Desktop.
Save gbluma/8550264 to your computer and use it in GitHub Desktop.
A deploy script that can look at old versions of code in Git
#!/bin/bash
function deploy() {
echo "Deploying tag: $1"
# create a working folder
mkdir -p "$DEPLOY_DIR/$1"
# dump code to this new folder
git archive $(cat .git/refs/tags/$1):src 2>/dev/null | \
tar -x -C "$DEPLOY_DIR/$1" 2>/dev/null
}
set +e
DEPLOY_DIR=www
# clean up old stuff
rm -Rf "$DEPLOY_DIR/*"
deploy "HEAD"
for tag in $(git tag); do
deploy $tag
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment