Compare Heroku ENV variables across environments in an HTML table.
In a perfect world, you're using a platform or tool for managing your environment variables across Heroku environments. However, you may find the need to compare review app settings, staging, or even production environment variables
This gem helps pull down the environment variables and give you a little interface to view & compare them with (via a UI)
The heavy lifting is done via the heroku platform-api gem to retrieve environment variables, format them in an HTML page, and generate a small HTML file and open it with launchy
It automates a few things:
- Hides environment variables that match across all environments
- Puts them in alpha order
It's primarily intended to compare pre-production ENV variables across similar/identical environments
# Install Heroku CLI
brew tap heroku/brew && brew install heroku
# Login with Heroku CLI
heroku login
# Install the heroku oauth plugin to generate an OAuth token
heroku plugins:install heroku-cli-oauth
# Create a token to access your applications
heroku authorizations:create -d "Platform API token for environment variables"
# Set the Token from above to an environment variable
export OAUTH_TOKEN=<token>
If you want to add the environment variable to your shell permanently, you can run a variation of the command below:
# Add permanently to `.bash_profile`
echo 'export OAUTH_TOKEN=<token>' >>~/.bash_profile
gem install env_compare
After installation you should have access to the ec
executable wrapper.
Use ec
command to start comparing 2 or more heroku application environment variables.
When only one application name is specified, output is shown in cli. Otherwise, your default browser is launched.
ec diff heroku-app-name1 heroku-app-name2 heroku-app-name3
add --all
option:
ec diff --all heroku-app-name1 heroku-app-name2 heroku-app-name3
--theme dark
default--theme light
For Example:
ec diff --theme light heroku-app-name1 heroku-app-name2
You can use ec update
to set or clear an environment variable across multiple Heroku
applications. This includes the options:
--key=
is required. The name of the Heroku environment variable you want to update.--value=
is optional. The value of the environment variable you want to update. If not provided, will unset the environment variable.--force
is a default option. Updates the environment variable, or adds it if not present. ** 0.1.3.pre.beta **--no-force
is optional. Only update the environment variable if present in the application. ** 0.1.3.pre.beta **
ec update heroku-app-name1 heroku-app-name2 heroku-app-name3 --key=MY_KEY --value=asdf
The default key value is nil; omit the --key
argument if you want to clear an
environment variable.
ec update heroku-app-name1 heroku-app-name2 heroku-app-name3 --key=MY_KEY
To test this on your machine locally, after cloning the repo:
git clone https://github.com/jaydorsey/env_compare.git && cd env_compare
bundle
bundle exec ec diff heroku-app-name1 heroku-app-name2
You can also optionally build & install the gem locally to test:
rake build
gem install pkg/env_compare.<version_number>.gem
Then, use the ec
command as normal.
If you have access to publish the gem on rubygems:
rake build
cd pkg
gem push env_compare.<version_number>.gem
Bug reports and pull requests are welcome on GitHub at https://github.com/jaydorsey/env_compare.