Skip to content

expression-context

GitHub Actionscorrectnessno fixdefault: offgithub-actions/actionlint

Reports an expression that reads a context, or calls a special function, that the key it is in does not offer (env in the env of a job, runner in a matrix).

Each key of a workflow can use only some contexts, since the others do not exist yet when it is evaluated. An expression that reads another one does not get its value.

To fix, use a context the key offers, or move the value to a key that has it.

Reported
...
a:
runs-on: ubuntu-latest
env:
A: ${{ env.B }}
C: ${{ github.sha }}
steps:
- run: echo ${{ env.B }} ${{ runner.os }}
if: ${{ always() }}
b:
runs-on: ubuntu-latest
if: ${{ runner.os == 'x' }}
steps:
- run: echo
github-actions:
lint:
rules:
expression-context: warn # off (default), warn, error

Enabled by the presets: github-actions/actionlint.

Suppress one line with sudsy-disable-next-line expression-context 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 expression/context partial The contexts and special functions each key offers (table in lang-github-actions/src/expression.rs).