How to write multi-line condition in if #25641
-
I used I thought this would work as expected, but the combination of Below is the workflow created for confirmation.
And the execution result is this. I thought that the last test6 was skipped, but it is not actually skipped. I think that there is something wrong with the Parser in GitHub Actions when I combine |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 4 replies
-
you need to use the symbol ‘|’ to set the multi-line condition.
Here is a same topic as reference:
@uditgaurav, You can write like as the following: - name: Running all tests if: | startsWith(github.event.comment.body, '/run-e2e-all') || startsWith(github.event.comment.body, '/run-e2e-first-test') || startsWith(github.event.comment.body, '/run-e2e-second-test') || startsWith(github.event.comment.body, '/run-e2e-third-test') || startsWith(github.event.comment.body, '/run-e2e-fourth-test') || startsWith(github.event.comment.body, '/run-e2e-fifth-test') || startsW… Note: if you use “${{ }}” to surround the condition, this will not work. |
Beta Was this translation helpful? Give feedback.
-
@brightran, Is it a specification that doesn’t work when using “|” and “${{ }}” together? |
Beta Was this translation helpful? Give feedback.
-
Yes, I agree. |
Beta Was this translation helpful? Give feedback.
-
Just an FYI for anyone wondering: Multiline condition works for assignment. So something like
HTH |
Beta Was this translation helpful? Give feedback.
-
[FYI to people that just found this discussion]
In the meantime it seems to work to combine Example:
|
Beta Was this translation helpful? Give feedback.
-
fwilhelm92:
This did not work for me. In my case the first conditional was evaluated and did not throw an error but the second never was. In your case, having || would not throw an error either unless you tested
However, @brightran 's example did work:
|
Beta Was this translation helpful? Give feedback.
-
My testing just now indicates that only
when the evaluation results in Note that if I remove the surrounding Which I find infuriatingly stupid if I am being honest. I've gnashed for 2 days now getting to the bottom of this. Trying alternate multi-line syntax was not something I had even considered could be a cause of why my |
Beta Was this translation helpful? Give feedback.
-
This is not working for me:
After adding this condition (inputs.TF_WORKING_DIR == '*test') , workflow is not working as expected. I have two directories:
So, I was trying to use |
Beta Was this translation helpful? Give feedback.
@kei-yamazaki,
you need to use the symbol ‘|’ to set the multi-line condition.
For example:
Here is a same topic as reference: