Reusable Workflows, Secrets and Environments

The workflow is not valid…
Unexpected value ‘uses’…
Unexpected value ‘with’.

Looks like ‘environment’ can’t be used without ‘steps’.

Jobs run in the order they’re defined and you’re referencing the outputs of one job before it runs…

Correct. If you look at the JSON scheme for workflows you’ll see that environment can be used in a normal job definition (in other words one with steps) but not when calling a reusable one.

@AllanOricil Your example greatly helped me figure out the correct way to pass environment secrets to reusable workflows. Thanks.

I’ve made a tutorial here if anyone still suffering trying to use Environment Varibles:

https://github.com/olivatooo/github-actions-build-deploy-with-staging-production-environment

1 Like

Thanks for the tutorial, it’s wild that there isn’t an easier way to reuse the same script with different secrets depending on the branch you’re on. I imagine most people take the “easier” way and just have prod and staging .yml scripts.