Per branch env vars

I know this has come up before, but now with circleCI 2.0 surely there must be an easier way to do this than having four env variables in the projects config and then doing this:

  - deploy:
      command: |
        if [ "${CIRCLE_BRANCH}" == "master" ]; then
          AWS_ACCESS_KEY_ID=${AWS_MASTER_KEY}
          AWS_SECRET_ACCESS_KEY=${AWS_MASTER_SECRET}
          serverless deploy --stage master
        fi
        if [ "${CIRCLE_BRANCH}" == "staging" ]; then
          AWS_ACCESS_KEY_ID=${AWS_STAGING_KEY}
          AWS_SECRET_ACCESS_KEY=${AWS_STAGING_SECRET}
          serverless deploy --stage staging
        fi

?

6 Likes

Anything new about it?

@levlaz @tom any updates from your side? Would be good to document if there is a better way to achieve the above.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.