Skip to content

if-condition

GitHub Actionscorrectnessno fixdefault: offgithub-actions/actionlint

Reports an if: that is a constant (if: false), or one with text around its ${{ }}, which makes it a non-empty string that is always true (if: ${{ a }} && ${{ b }}).

A string with text around the expression is never false, even when the expression is false, so the step or job always runs. A constant condition is left in by mistake after a test.

To fix, write the whole condition inside one ${{ }}, or without it.

Reported
...
runs-on: ubuntu-latest
steps:
- run: echo
if: false
- run: echo
if: ${{ github.ref }} && true
- run: echo
if: "${{ github.ref == 'x' }} "
- run: echo
if: github.ref == 'x' && !cancelled()
- run: echo
...
github-actions:
lint:
rules:
if-condition: warn # off (default), warn, error

Enabled by the presets: github-actions/actionlint.

Suppress one line with sudsy-disable-next-line if-condition in a comment of the file’s language.

The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.

Tool Rule Match What differs
actionlint if-cond partial Constant conditions and text around the markers of an if:.