I am looking to have a set of workflow level environment variables that take different values depending on the environment the workflow is running on. Below is how I am looking to do this:
name: Test workflow file
on:
workflow_dispatch
env:
GH_ENV_VAR: ${{ contains(github.ref, 'main') && 'prod' || contains(github.ref, 'feature-branch') && 'dev' || 'cert' }}
GH_ENV_VARIABLE: ${{ env.GH_ENV_VAR == 'dev' && 'DEV' || 'DO NOT KNOW'}}
USER_ACCOUNT: sample
WAREHOUSE: small
I am seeing the following error:
Invalid workflow file
The workflow is not valid. .github/workflows/workflow-file.yml (Line: 8, Col: 20): Unrecognized named-value: 'env'. Located at position 1 within expression: env.GH_ENV_VAR == 'dev' && 'DEV' || 'DO NOT KNOW'
You cannot use env. scope when creating env variables.
Even though it may look ok and you expect to have GH_ENV_VAR already there - it's not possible in workflows.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With