docs icon indicating copy to clipboard operation
docs copied to clipboard

GitHub Actions expressions example is misleading

Open kbattocchi opened this issue 2 years ago • 2 comments

Code of Conduct

What article on docs.github.com is affected?

https://docs.github.com/en/actions/learn-github-actions/expressions#example-of-literals

What part(s) of the article would you like to see updated?

Unfortunately, everything in env is apparently converted to a string (see https://github.com/orgs/community/discussions/25645), though as far as I can tell this isn't documented anywhere (but it should be!).

This makes the section where literals of various types are being assigned to environment variables especially misleading - you can use those literal expressions in the env section, but the values that are actually stored are the converted strings, which may then break downstream logic that uses the values while expecting them to have the correct type. This is especially true of boolean values, since the string 'false' is truthy.

Additional information

No response

kbattocchi avatar Jun 30 '23 15:06 kbattocchi

Thanks for opening this issue. A GitHub docs team member should be by to give feedback soon. In the meantime, please check out the contributing guidelines.

welcome[bot] avatar Jun 30 '23 15:06 welcome[bot]

@kbattocchi Thanks so much for opening an issue! I'll triage this for the team to take a look :eyes:

cmwilson21 avatar Jun 30 '23 20:06 cmwilson21

@kbattocchi - Thanks for raising this issue.

as far as I can tell this isn't documented anywhere (but it should be!).

You're right, stringifying the contents of the env context is something we should have documented. However, we added this quite recently here:

Using the ${{ }} expression syntax turns the contents into a string, and strings are truthy. For example, if: true && ${{ false }} will evaluate to true.

I'm going to close this issue. Thanks again for pointing this out. 👍

hubwriter avatar Aug 18 '23 13:08 hubwriter