It would be nice to be able to use environment variables in if conditionals.
While I can use an if condition in a runs definition, the step will still be marked as run (successfully, perhaps). If we could use if conditionals for the same thing, the step would be marked as ignored.
Any progress on this? When you're reading this documentation it sounds like `env` context is usable but following code still fails.
jobs: example-job: env: EVENT_LABEL: example-label if: github.event.label.name == env.EVENT_LABEL runs-on: ubuntu-latest steps: ...
Your workflow file was invalid: The pipeline is not valid. Unrecognized named-value: 'env'. Located within expression: github.event.label.name == env.EVENT_LABEL
Setting value directly works like expected:
if: github.event.label.name == 'example-label'
It might be that job-level "env" context is populated after job-level "if" is tested. It's a long shot, but i'd try if setting EVENT_LABEL at workflow-level "env" would help.
If not, you still can get (kinda) wanted behavior by moving check step-level:
check-label: runs-on: ubuntu-latest env:
- run: do-foo-thing
if: github.event.label.name == env.LABEL_FOO
- run: do-bar-thing
if: github.event.label.name == env.LABEL_BAR
- run: post-on-stackoverflow
if: github.event.label.name == env.LABEL_HELP
- run: send-flowers --color random
if: github.event.label.name == env.LABEL_BOOM
Most likely not a solution for everyone; it starts workflow, after all, which might be unwanted for few reasons. Packing N different, complex tasks into single job can be meh too. But if various simple tasks share some step(s), it might be nice.