Created
January 6, 2017 09:09
-
-
Save themasch/5cfeb2c97cbe3099a715584aa6c8572e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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