Skip to content

Actions workflow syntax: if without expression syntax ${{ }} can result in YAML syntax error #22392

Description

@victorlin

Code of Conduct

What article on docs.github.com is affected?

Anything that uses reusables.actions.expression-syntax-if, which states:

When you use expressions in an if conditional, you may omit the expression syntax (${{ }}) because GitHub automatically evaluates the if conditional as an expression.

So, at least the following:

  1. https://docs.github.com/en/actions/learn-github-actions/expressions
  2. https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idif

What changes are you suggesting?

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.

Additional information

No response

### Tasks

Metadata

Metadata

Assignees

No one assigned

    Labels

    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

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions