My main idea here is to have two separated environments - one for production
and one for staging
.
For that purpose, I created two repos on Heroku (I wasn't sure it was possible to make it with one repo)
version: 2.1
jobs:
heroku/deploy-via-git:
docker:
- image: circleci/node:10.16.3
steps:
- checkout
- run:
name: build-dev-step
command: echo $HEROKU_APP_NAME "This is Heroku env variable"
setting_development_variables:
docker:
- image: circleci/node:10.16.3
environment:
HEROKU_APP_NAME: ****
steps:
- checkout
- run:
name: setting-variables-command
command: echo "Heroku env variables are set"
setting_production_variables:
docker:
- image: circleci/node:10.16.3
environment:
HEROKU_APP_NAME: ***2***
NODE_ENV: production
steps:
- checkout
- run:
name: setting-variables-command
command: echo "Heroku env variables are set"
orbs:
heroku: circleci/[email protected]
workflows:
production:
jobs:
- setting_production_variables:
filters:
branches:
only:
- main
- heroku/deploy-via-git:
requires:
- setting_production_variables
filters:
branches:
only:
- main
development:
jobs:
- setting_development_variables:
filters:
branches:
only:
- staging
- heroku/deploy-via-git:
requires:
- setting_development_variables
filters:
branches:
only:
- staging
Here you can see the way of how I am trying to make it work for me but it seems I cannot set any env there, neither HEROKU_APP_NAME
nor NODE_ENV
.
For production when I set env variable in project settings, it works fine for me. But When I try to set it here in the config file it doesn't want to work.
What am I doing wrong here that it doesn't want to set env variables for me? Or maybe there is a better way to separate modes between Heroku and CircleCI?
EDIT:
As I understand NODE_ENV
variable I should set on a side of Heroku via CircleCI command, right? Not the way I am setting it here
if anyone face the same situation, that's how I solved it