1

I would like to set env variables depending on the branch. I have two branches 'master', and 'develop'. In each case I would like to define the following workflow env varialbes:

# for the master branch
env:
  host: test.example.com
  compose_file: docker-compose.staging.yml

# for the develop branch
env:
  host: api.example.com
  compose_file: docker-compose.prod.yml

How can I do that?

Currently I have two files which are copies of each other, with only the env variables changed.

I've seen that you can use ${{}} to evaluate expression. Is that the way to go?

Ynv
  • 1,824
  • 3
  • 20
  • 29
  • have two job/steps which each have own env sections then follow this to target which job is run on which branch https://stackoverflow.com/questions/58139406/only-run-job-on-specific-branch-with-github-actions – Lawrence Cherone Aug 10 '20 at 14:11
  • thanks for your reply. Are the env variables set by one job going to persist to the other jobs? – Ynv Aug 10 '20 at 14:14
  • Variables declared in `jobs..env` only exist for that job, and variables declared in the top-level `env` can't use any fancy logic. – Benjamin W. Aug 10 '20 at 14:18
  • Ah, I did not find this one. Thanks. Looks like a work-around, but I'll try. – Ynv Aug 10 '20 at 14:33

0 Answers0