-
Notifications
You must be signed in to change notification settings - Fork 962
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
If condition are always evaluated as true when containing expression syntax inside #1173
Comments
@dlavrenuek you can enable debug log to see how the expression gets evaluated. |
@TingluoHuang Here are the logs for the step: - name: false positive with expression syntax evaluation
if: github.ref == 'refs/head/${{ env.TEST_BRANCH }}' # is always executed
run: echo "runs"
|
And logs for - name: false positive with expression syntax evaluation
if: false && '${{ env.EMPTY_VALUE }}' # is always executed
run: echo "runs"
|
any solution? |
@TingluoHuang , can you please remove the |
I've opened a #1395 with a similar result, but the syntax is |
Bump |
I ran into this issue recently too and the way I got expressions to work in - name: false positive with expression syntax evaluation
if: github.ref == format('refs/heads/{0}', env.TEST_BRANCH)
run: echo "::error::This step should be skipped and not run!" && false
|
The string |
+1 |
+1 How can we solve this? |
From full to lite model (Bicleaner AI) actions/runner#1173
Having the same issue with the if statement check as shown below. Always returns true...
|
How can this still be an issue almost a year on? Kinda disappointed really as this is quite a fundamental part. |
After spending lot of time understanding this i achieved what i want by comparing with the string values of |
Honestly losing faith in actions - they're just not stable and powerful enough to run organisation-level workflows. |
I fixed like this |
@joshghent this should work in your case:
|
I'm encountering the same issue, this always evaluates to
And this is syntactically incorrect so I can't use it:
|
What year is it? |
Just needs to be fixed in the documentation... it says all over to use the ${{ }} syntax which is invalid for if statements. |
I am having the same issue.
Here is the debug log:
I have tried adding
|
This issue will be fixed? |
@benoit-cty Sir, I am forever grateful for your help! I had been sitting 5 hours on this problem, but your reply really helped. Thank you! |
CC: actions/runner#1173 Signed-off-by: simonsan <[email protected]>
Github actions suuucks |
Seriously the bad syntax in the docs since 2021 !! wtf? actions/runner#1173 Signed-off-by: WoodenMaiden <[email protected]>
Seriously the bad syntax in the docs since 2021 !! wtf? actions/runner#1173 Signed-off-by: WoodenMaiden <[email protected]>
I changed the syntax in the condition from e.g. if: ${{steps.step_id.outputs.output_var}} == 'string' to if: ${{steps.step_id.outputs.output_var == 'string'}} that seems to work |
Noticed an error when this action was run even though the actor wasnt matching. According to actions/runner#1173, you should be really careful when using ${{ }} inside if statements.
- fix setting all suites to aws - simplify logic to avoid actions/runner#1173
Wow, it is kinda amazing that, this basic thing does not work as expected. |
Confirming this works. Also found some documentation that may be helpful, regarding the |
This GHA shows the result of various string comparisons in Whole predicate wrapped in
|
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
Example run: https://github.com/dlavrenuek/test-workflow-if-condition/runs/2914408827?check_suite_focus=true
Example step definition:
In the example workflow the last two steps should not have been run, but they were
To Reproduce
Steps to reproduce the behavior:
if
condition with expression syntax${{ ... }}
as part of the condition (not wrapping the whole condition)Expected behavior
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
The text was updated successfully, but these errors were encountered: