Skip to content

Instantly share code, notes, and snippets.

@wffurr
Last active February 20, 2017 00:51
Show Gist options
  • Save wffurr/bd7da7028993378629d7fa536572bd1a to your computer and use it in GitHub Desktop.
Save wffurr/bd7da7028993378629d7fa536572bd1a to your computer and use it in GitHub Desktop.
#!/bin/bash
print_usage() {
echo "Usage: ./deploy.sh [staging|prod]"
exit 1
}
ENVS=( prod staging )
if [[ $# -lt 1 ]]; then
print_usage
fi
if ! [[ ${ENVS[*]} =~ "$1" ]]; then
print_usage
fi
if ! [[ -e "config.local.json.$1" ]]; then
echo "Missing config.local.json.$1 for deployment"
exit 1
fi
echo "Using config.local.json.$1 for push"
cp config.local.json config.local.json.bak
cp config.local.json.$1 config.local.json
git add -f config.local.json
git commit -m "Committing config.local.json for deployment"
echo "Deploying to $1"
git push -f $1 master
echo "Resetting config.local.json"
git reset HEAD^
mv config.local.json.bak config.local.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment