├── heroku-config.py └── README.md /heroku-config.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | def removeQuotesFromValue(value): 4 | value = value.replace("'", '"') 5 | # value = value.replace('"', "") 6 | return value 7 | 8 | def splitLineIntoParts(line): 9 | line = line.lstrip() 10 | line = line.rstrip() 11 | line = removeQuotesFromValue(line) 12 | line = line.split("=", 1) 13 | return line 14 | 15 | def setConfigVar(name, value): 16 | os.system('heroku config:set ' + name + '=' + value) 17 | 18 | with open('.env') as e: 19 | 20 | for line in e: 21 | l = splitLineIntoParts(line) 22 | if (len(l) > 1): 23 | name = l[0] 24 | value = l[1] 25 | print() 26 | print ("*** Setting " + name + " = " + value + " ***") 27 | setConfigVar(name, value) 28 | 29 | 30 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Heroku Config 2 | This python script helps you set all your heroku config vars directly from a .env file, instead of having to load them in one by one. 3 | This script works especially for laravel, but can be used for any other environment, all you just need do is to have a `.env` file, and have your variables set like APP_NAME=your_app_name 4 | 5 | ### Requirements 6 | * python runtime (2.7+) 7 | * heroku toolbelt (CLI) 8 | * A project already connected to heroku 9 | 10 | ### Installation and Usage 11 | * Clone or download this repo, then copy the `heroku-config.py` file into the root directory of your project (or wherever your .env file is located) 12 | * Or download the `heroku-config.py` directly from git into the same location as your .env file 13 | - From the cmd, `cd` into the location of your .env file e.g ``cd C:/projects/your heroku project`` 14 | - Run `python heroku-config.py` . You should see your config vars getting set on after the other 15 | - That's all 16 | 17 | ### Now you can spend your time saving the world instead of setting Config Vars. 18 | --------------------------------------------------------------------------------