You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Actions workflow syntax: if without expression syntax ${{ }} can result in YAML syntax error #22392
actionsThis issue or pull request should be reviewed by the docs actions teamcontentThis issue or pull request belongs to the Docs Content teamwaiting for reviewIssue/PR is waiting for a writer's review
When you use expressions in an if conditional, you may omit the expression syntax (${{ }}) because GitHub automatically evaluates the if conditional as an expression.
These articles suggest that ${{ }} can always be omitted from an if conditional. However, that is not the case since this results in a YAML syntax error (evidence):
if: !false || false
Wrapping it in ${{ }} allows the expression to be evaluated properly (evidence):
if: ${{ !false || false }}
I suggest changing the wording to highlight this limitation.
the reason ${{ }} is "required" despite the docs saying it isn't is because the file still has to be valid YAML syntax. While strings in YAML can normally be unquoted, there are exceptions where quotes are required, such as when specific YAML metachars are present in the string. The leading !... | construct here in the condition is the culprit that requires quoting, as it's a type tag (!...) and block scalar start (|). So the ${{ }} changes that by making the !... no longer a type tag, and thus the | no longer a block scalar start. The point is that using normal YAML quoted strings:
actionsThis issue or pull request should be reviewed by the docs actions teamcontentThis issue or pull request belongs to the Docs Content teamwaiting for reviewIssue/PR is waiting for a writer's review
Activity
sync-rtd-redirects: Skip on fork repositories
cmwilson21 commentedon Dec 1, 2022
@victorlin Thanks so much for opening an issue! I'll triage this for the team to take a look 👀
victorlin commentedon Dec 1, 2022
A nice explanation from @tsibley in nextstrain/.github#33 (comment):
lucascosti commentedon Dec 1, 2022
Thanks for opening this issue, @victorlin!
Yep, as you discovered in your comment, you can't begin YAML values with some special characters unless you quote them.
This applies to all YAML values, not just for GitHub Actions or the
ifkey, so a doc update probably isn't required here.