Reputation: 81
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'
Upvotes: 3
Views: 3307
Reputation: 19792
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.
Upvotes: 1