1

For example, travis-ci.com allows the user to define an env variable which is bound to a certain branch. Whereas Github does allow you to define secret env variables, they, however, all have to compete for the same namespace which introduces additional complexity. Does anyone know a workaround?

Mateja Petrovic
  • 3,799
  • 4
  • 25
  • 40

2 Answers2

1

As an alternative, you can create an environment on GitHub. And you can create secrets for that environment. And finally, you can add a deployment branch for that environment. That means you could have a job to deploy to that environment using that secret. Only that job would have access to the secret and you can also set a rule to only allow deploys to that environment using workflows on that branch.

I think, that way you get what you want (or maybe a little bit more restrictive) because only that branch would have access to the secret but you have to define an environment. I suppose in most cases when you introduce a secret that depends on a branch it's because that branch represents an environment.

Jose Celano
  • 539
  • 1
  • 7
  • 14
0

I have not seen that particular feature, which means you need to define your variable environment with a naming convention:

branchName_myVariable

In your GitHub Action script, you can then reference said variable by prepending the branch name you would have extracted in a separate step.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250