Boolean based on workflow conditions #27029
-
How would you go about creating a boolean variable, which switches its value based on certain conditions ? The variable is used inside a script in the workflow. I’ve came up with this solution through Powershell:
And of course it works, but I was thinking about a solution that is YAML only. The thing is, I can’t think of any 😃 Any ideas ? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
You mean like this?
|
Beta Was this translation helpful? Give feedback.
-
It was quite some time ago, but I think I meant grouping conditions inside a single variable.
Several months later, I don’t think that’s possible in YAML, but correct me if I am wrong. |
Beta Was this translation helpful? Give feedback.
-
Well, you could evaluate an expression in place, like this:
But the Or do you mean to defer evaluation? As in have |
Beta Was this translation helpful? Give feedback.
-
That’s it! Thank you! |
Beta Was this translation helpful? Give feedback.
Well, you could evaluate an expression in place, like this:
But the
env
context is only available in steps, so the third condition wouldn’t be possible like this.Or do you mean to defer evaluation? As in have
github.event_name == 'push' && github.ref == 'refs/heads/master' && env.BUILD_CONFIGURATION == 'Release'
as string and then evaluate that string in certain places of the workflow, something along${{ eval(env.condition) }}
? That is definitely not supported, and I would guess it’s very unlikely to ever get supported because of security concerns.