if-condition
What it does
Section titled “What it does”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 }}).
Why it matters
Section titled “Why it matters”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.
Example
Section titled “Example”... 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...Configuration
Section titled “Configuration”github-actions: lint: rules: if-condition: warn # off (default), warn, errorEnabled by the presets: github-actions/actionlint.
Suppress one line with sudsy-disable-next-line if-condition in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”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:. |