Skip to content

InvalidExpressionUsage

Step uses must not contain expressions.

Defined by InvalidExpressionUsageRule which supports workflows, actions in the "Default" ruleset.

Description

GitHub Action Expressions can be used to programmatically access context variables in workflow files. -- About expressions

However, they cannot be used within steps[*].uses. GitHub will report an error:

The workflow is not valid. .github/workflows/???.yml (Line: ?, Col: ?): A template expression is not allowed in this context

Compliant example

GitHub Expression not used within uses.

example.yml

on: push
jobs:
  example:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

Non-compliant example

GitHub Expression used within uses.

example.yml

on: push
jobs:
  example:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@${{ github.ref }}

  • Line 6: Step[actions/checkout@${{ github.ref }}] in Job[example] contains a GitHub expression in the uses field.