Skip to content

Instantly share code, notes, and snippets.

@themasch
Created January 6, 2017 09:09
Show Gist options
  • Save themasch/5cfeb2c97cbe3099a715584aa6c8572e to your computer and use it in GitHub Desktop.
Save themasch/5cfeb2c97cbe3099a715584aa6c8572e to your computer and use it in GitHub Desktop.
#!/bin/bash
declare -A deployTo
deployTo[development]="/home/masch/gitdeploy/dev"
deployTo[master]="/home/masch/gitdeploy/prod"
gitDir="/home/masch/gitdeploy/deploy.git"
function deploy() {
branch=$1
directory=$2
echo "git --work-tree=${directory} --git-dir=${gitDir} checkout -f $branch"
}
while read -r line
do
opts=($line)
branch=${opts[2]}
if test "${deployTo[$branch]+isset}"
then
echo "deploying branch ${branch} to ${deployTo[$branch]}"
deploy "${branch}" "${deployTo[$branch]}"
else
echo "not deploying branch ${branch}"
fi;
done < /dev/stdin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment