Skip to content

Instantly share code, notes, and snippets.

@przbadu
Created April 24, 2018 06:18
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 przbadu/3c804ae21e9e89c58035a05e898c67d9 to your computer and use it in GitHub Desktop.
Save przbadu/3c804ae21e9e89c58035a05e898c67d9 to your computer and use it in GitHub Desktop.
copy heroku config vars from source app to target app.
#!/bin/bash
# Author: przbadu
#
# Usage: heroku-copy-config <source> <target>
set -e
sourceApp="$1"
targetApp="$2"
config=""
message="Usage: heroku-copy-config <source> <target>"
# colors
RED="\033[1;31m"
GREEN="\033[1;32m"
ORANGE="\033[0;33m"
BLUE="\033[1;34m"
NC='\033[0m' # no color
if [[ -z "$sourceApp" ]]; then
echo -e "$message"
elif [[ -z "$targetApp" ]]; then
echo -e "$message"
else
printf "Pulling config vars from ${RED}${sourceApp}${NC}..."
while read line; do
if [[ $line == QBO_* ]]; then
if [[ $line == QBO_REDIRECT_URL* ]]; then
config="$config QBO_REDIRECT_URL=https://${targetApp}.herokuapp.com/quickbooks/oauth2_callback"
elif [[ $line == QBO_HOST_URL* ]]; then
config="$config QBO_HOST_URL=https://${targetApp}.herokuapp.com/"
else
config="$config $line"
fi
fi
done < <(heroku config --app "$sourceApp" --shell )
printf " done\n"
echo -e "Pushing config vars to ${ORANGE}$targetApp"
eval "heroku config:set $config --app $targetApp"
echo -e "setup was ${GREEN}successful!!"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment