-
-
Save stopanko/77dfa4826ba0dd765dc35982bb208b1a to your computer and use it in GitHub Desktop.
Script to copy environment variables from an existing heroku app to another one
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
# https://emirkarsiyakali.com/heroku-copying-environment-variables-from-an-existing-app-to-another-9253929198d9 | |
# Bash script | |
heroku config -s -a existing-heroku-app > config.txt | |
cat config.txt | tr '\n' ' ' | xargs heroku config:set -a new-heroku-app | |
# Ruby Script | |
#!/usr/bin/env ruby | |
require 'json' | |
source_app = ARGV[0] | |
dest_app = ARGV[1] | |
ignore = %w(DATABASE_URL) | |
vars = JSON.parse `heroku config --app #{source_app} --json` | |
vars.each do |key, value| | |
next if ignore.include?(key) | |
`heroku config:set #{key}="#{value}" --app #{dest_app}` | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment