Karol Selak
Karol Selak

Reputation: 4774

How to load env variables from yml file to Heroku?

I have many environment variables defined in yml file. I use this file locally for configuration. How can I set these variables on my Heroku server without adding my file to repo? My app is built on Ruby on Rails.

Upvotes: 1

Views: 487

Answers (2)

schmijos
schmijos

Reputation: 8695

If you would like to reinvent the wheel… here's a kind of wheel:

heroku config:set $(cat config/application.yml | grep "^[^\#\ ].*\:\ .*$" | sed 's/\:\ /=/g' | tr "\n" " ")

It parses top-level keys of a Figaro YAML file.

Update:

You actually can use Figaro's heroku:set to reach the same result:

$ figaro help heroku:set
Usage:
  figaro heroku:set

Options:
  -a, [--app=APP]                  # Specify a Heroku app
  -e, [--environment=ENVIRONMENT]  # Specify an application environment
  -p, [--path=PATH]                # Specify a configuration file path
                                   # Default: config/application.yml
  -r, [--remote=REMOTE]            # Specify a Heroku git remote

Send Figaro configuration to Heroku

Upvotes: 1

jvillian
jvillian

Reputation: 20263

Don't reinvent the wheel. Check out the Figaro gem. From the github page:

Simple, Heroku-friendly Rails app configuration using ENV and a single YAML file.

Upvotes: 0

Related Questions