expressions

contains / startsWith / format / join / fromJSON

Built-in functions available inside `${{ }}` expressions. GitHub Actions does not allow user-defined functions — only the documented list is valid.

${{ <function>(<args>) }}

Common values / subkeys

Value / Subkey Purpose
contains(search, item) Substring or array membership test (case-insensitive for strings)
startsWith / endsWith(str, needle) Prefix / suffix test
format('{0}-{1}', a, b) Positional string formatting
join(array, sep) Join an array into a string
toJSON / fromJSON Serialize to / parse from JSON
hashFiles('glob', ...) SHA-256 of matching files, ideal cache key
success / failure / cancelled / always Job/step status predicates

Examples

if: ${{ startsWith(github.ref, 'refs/tags/v') }}

Only run on version tags

with:
  key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}

Cache key derived from a lockfile hash

run: echo ${{ join(matrix.tags, ',') }}

Comma-join a matrix array into a string

strategy:
  matrix: ${{ fromJSON(needs.setup.outputs.matrix) }}

Parse JSON from an upstream output into a matrix

Gotcha

`contains()` is case-insensitive when comparing strings but strictly equal for array items; `toJSON` produces a string that consumers must re-parse with `fromJSON`.

Related keywords

← All GitHub Actions syntax · Git commands · Cron syntax