-
Notifications
You must be signed in to change notification settings - Fork 60.4k
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
Document truthiness handling for expressions #23795
Comments
👋 @jsoref Thanks so much for opening an issue! I'll triage this for the team to take a look 👀 |
@jsoref - reopened! Sorry about that! 👍 |
@jsoref - Thanks for raising this. We've added the following to that article recently:
I think this answers you in situations where you enclose the expression in an if statement in It would, however, be useful to be clear, in the article about I think it would be helpful to add a little paragraph (perhaps a subsection) in https://docs.github.com/en/actions/using-jobs/using-conditions-to-control-job-execution stating explicitly what evaluates to true and false, for the avoidance of doubt. It would be great if someone would care to pick this up, do a little testing to establish the situation, and write this up in a PR. I'll label this issue |
I'd like to get started with this issue. Determining Truthiness and Falseness in GitHub Actions In GitHub Actions, understanding when a value is considered "true" or "false" is crucial for crafting effective conditional statements. The evaluation of truthiness and falsiness in GitHub Actions can be summarized as follows: ${{ ... }} Expressions: Unset Variables: String Variables: Numeric Variables: |
@SoundaryaKoutharapu Thanks for your interest! I think it'll be fine to proceed with the PR, and then we can suggest any edits or updates in the review process ✨ |
I think an empty string ( |
Code of Conduct
What article on docs.github.com is affected?
https://docs.github.com/en/actions/learn-github-actions/expressions
What part(s) of the article would you like to see updated?
Some part of the page should explain how:
works. Specifically, if
vars.FOO
isn't set, that's presumably treated as the equivalent of an empty something (string?).if
vars.FOO
is set, it's presumably treated as a string.Note that I'm using
vars
above, but the same applies for anything that would naturally be stringy (env
,inputs
(that are stringy),secrets
,outputs
,....)Are all non-empty strings true?
Is the string
"0"
true?Is the string
"false"
true?There's some prose that says that when comparing two things, if they're of different types, they're converted to numbers.
But it isn't particularly clear if,
if: ${{ some_expression }}
is treated asif: ${{ (some_expression) == true }}
which thus results in strings being converted to numbers and true being converted to a number.Additional information
[maintainer edit]
Content plan here
The text was updated successfully, but these errors were encountered: