What Is an Expression in GitHub Actions?
An expression is the code inside ${{ }} that GitHub evaluates to compute values, build strings, and decide conditions.
GitHub Actions YAML is mostly static, but expressions add logic. Anything between ${{ and }} is evaluated by GitHub using contexts, operators, and built-in functions before the step runs.
What it is
An expression is a small formula wrapped in ${{ }}. It can read context data, call functions like contains() or format(), and use operators such as ==, &&, and ||.
steps:
- if: ${{ github.ref == 'refs/heads/main' }}
run: ./deploy.sh
- run: echo "${{ format('Build {0}', github.run_number) }}"How it works
GitHub evaluates expressions when it processes the workflow, substituting the result into the YAML. In if: conditions the surrounding ${{ }} is optional because the whole value is treated as an expression.
Functions and operators
Expressions support comparison and logical operators plus functions like contains, startsWith, fromJSON, and the status checks success() and failure(). These power conditional steps and dynamic values.
Why it matters
Expressions make workflows dynamic: skip steps on the wrong branch, build version strings, or branch on previous results. They are the glue between static YAML and runtime data.
Related concepts
Expressions read from contexts and are commonly used in if: conditions, matrices, and concurrency keys.
Key takeaways
- An expression is logic inside
${{ }}. - It uses contexts, operators, and functions.
- In
if:the${{ }}wrapper is optional.