Skip to content
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

isTeamMember returns string instead of boolean #24

Open
glebviniarskii opened this issue Jan 19, 2024 · 2 comments
Open

isTeamMember returns string instead of boolean #24

glebviniarskii opened this issue Jan 19, 2024 · 2 comments

Comments

@glebviniarskii
Copy link

echo "output 1 ${{steps.teamAffiliation.outputs.isTeamMember == 'false'}}"
echo "output 2 ${{steps.teamAffiliation.outputs.isTeamMember == 'true'}}"
echo "output 3 ${{steps.teamAffiliation.outputs.isTeamMember == false}}"
echo "output 4 ${{!steps.teamAffiliation.outputs.isTeamMember}}"

изображение
Really curious about this behavior, first noticed it when if returned false from false == false expression in checking conditions for step

@tspascoal
Copy link
Owner

That is correct, outputs are always strings.

The behavior for comparisons in expressions is documented here (see the Note)

If you want to force coercion to a boolean you can do something like this

echo "output 2 ${{ fromJSON(steps.teamAffiliation.outputs.isTeamMember) == true}}"

Some examples

echo ${{ false == 'false' }} # false
echo ${{ 'false' == false }} # false
echo ${{ fromJSON('false') == false }} # true

So it is always better to compare strings for equality

Apologies for the vagueness in the README that lead to this confusion I will add a note to make it more clear.

@tspascoal
Copy link
Owner

@glebviniarskii created issue #25 to make this clear.

Thank you for bringing this up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants