Skip to content

Instantly share code, notes, and snippets.

@joaofnds
Last active June 16, 2019 15:12
Show Gist options
  • Select an option

  • Save joaofnds/567529ab94dc2a8298cc1455cc9c82b2 to your computer and use it in GitHub Desktop.

Select an option

Save joaofnds/567529ab94dc2a8298cc1455cc9c82b2 to your computer and use it in GitHub Desktop.
remove all heroku env variables except for database_url. Call it with `ruby heroku_clear_env.rb my-app`
require 'json'
app = ARGV[0]
envs_to_ignore = ['DATABASE_URL']
keys =
JSON.parse(`heroku config --app #{app} --json`)
.reduce('') do |memo, (key, _value)|
if envs_to_ignore.include? key
memo
else
memo + "#{key} "
end
end
`heroku config:unset --app #{app} #{keys}`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment