Description
What article on docs.github.com is affected?
What part(s) of the article would you like to see updated?
There's a reusable ({% data reusables.github-actions.expression-syntax-if %}
) in this document that contains the info:
When you use expressions in an if conditional, you may omit the expression syntax (
${{ }}
) because GitHub automatically evaluates theif
conditional as an expression.
However, I just made a small example run with a job's if
conditional like:
post-build:
runs-on: ubuntu-latest
needs: build
if: !startsWith(needs.build.outputs.sha8, needs.build.outputs.short-sha)
steps:
# ...
and it failed with a syntax error in the if
statement: The workflow is not valid. .github/workflows/release.yml: Unexpected tag '!startsWith(needs.build.outputs.sha8,'
(see here).
The run succeeds when the expression is surrounded by ${{}}
:
post-build:
runs-on: ubuntu-latest
needs: build
if: ${{!startsWith(needs.build.outputs.sha8, needs.build.outputs.short-sha)}}
steps:
# ...
I'd fix this in a PR if I knew where to find the reusable, but it wasn't immediately transparent, so I'm submitting an issue instead. If anyone could point me to where {% data reusables.github-actions.expression-syntax-if %}
is defined, I'll happily make a PR with the required changes. It seems that expressions must be explicitly indicated for evaluation if they contain any operators.
Additional information
- Syntax-erroring test run where documentation was false: https://github.com/jidicula/test-actions/actions/runs/496429121
- Permalink to offending if condition with an expression containing the
!
operator with no surround${{}}
: https://github.com/jidicula/test-actions/blob/39946fb7867001386eb671c9f84dfc3a7443dedd/.github/workflows/release.yml#L56 - Test run where surrounding if statement expression with
${{}}
succeeded without syntax error: jidicula/test-actions@628f8ff - Permalink to correct syntax if statement with an expression containing a
!
operator surrounded by${{}}
: https://github.com/jidicula/test-actions/blob/628f8ffcdc02ae43dec64ad076e3dbd114633836/.github/workflows/release.yml#L56