If condition are always evaluated as true when containing expression syntax inside
Problem
Describe the bug An if condition in a step definition that includes expression syntax in condition body is always evaluated as false positive or is ignored. Example workflow: https://github.com/dlavrenuek/test-workflow-if-condition/blob/master/.github/workflows/test.yml [code block] Example run: https://github.com/dlavrenuek/test-workflow-if-condition/runs/2914408827?check_suite_focus=true Example step definition: [code block] In the example workflow the last two steps should not have been run, but they were To Reproduce Steps to reproduce the behavior: 1. create a workflow 2. add an `if` condition with expression syntax `${{ ... }}` as part of the condition (not wrapping the whole condition) 3. trigger the workflow Expected behavior - [ ] The if condition should be correctly evaluated. - [ ] In case that the expression syntax is not supported as part of an `if` condition - an error should be thrown instead of silently ignoring it. Runner Version and Platform GitHub platform What's not working? The steps are executed because of false positive evaluation of he if condition containing expression syntax <img width="541" alt="Bildschirmfoto 2021-06-25 um 15 31 17" src="https://user-images.githubusercontent.com/20122620/123432628-df378580-d5ca-11eb-8f0a-8f2bfa7a488d.png">
Error Output
error should be thrown instead of silently ignoring it.
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: If condition are always evaluated as true when containing expression syntax inside
I ran into this issue recently too and the way I got expressions to work in `if` correctly was to use the `format` function. Please try this: [code block]
Trust Score
3 verifications
- 1
I ran into this issue recently too and the way I got expressions to work in `if`
I ran into this issue recently too and the way I got expressions to work in `if` correctly was to use the `format` function. Please try this:
Validation
Resolved in actions/runner GitHub issue #1173. Community reactions: 2 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep