How can I set an environment variable before each build on heroku?

721 Views Asked by At

I have a create-react-app and I need an automated way to set an different environment variables before each build. My goal is to set a code_version for Rollbar.

I tried the following:

  1. "heroku-prebuild": "heroku config:set REACT_APP_ROLLBAR_CODE_VERSION=test123 && sh upload-source-maps-script.sh" error message: /bin/sh: 1: config:set: not found

  2. "heroku-prebuild": "sh upload-source-maps-script.sh" and from within sh file heroku config:set REACT_APP_ROLLBAR_CODE_VERSION=test123 error: no error message, but config var is not set

  3. Also from within sh file export REACT_APP_ROLLBAR_CODE_VERSION=test123

1

There are 1 best solutions below

0
On
 heroku config:set <YOUR_KEY>=<YOUR_VALUE>