Skip to content
Latchkey

GitHub Actions Environment Variable Not Expanding in Steps

An environment variable is empty or appears literally because the expansion syntax is wrong, or because a value set in one step is read in another without being written to GITHUB_ENV.

What this error means

A step prints an empty value, or the literal text ${{ ... }}, where you expected a variable. Setting a variable with export in one step has no effect on later steps.

.github/workflows/ci.yml
- run: export VERSION=1.2.3
- run: echo "Deploying $VERSION"   # prints "Deploying " - empty

Common causes

Each run step is a fresh shell

A shell variable exported in one run step does not persist to the next. Steps share the job environment only through GITHUB_ENV.

Mixing expression and shell syntax

GitHub evaluates ${{ }} before the shell runs, while $VAR is expanded by the shell. Using the wrong one for the context yields empty or literal output.

How to fix it

Persist values via GITHUB_ENV

Write the variable to GITHUB_ENV so later steps in the same job can read it as an env var.

.github/workflows/ci.yml
- run: echo "VERSION=1.2.3" >> "$GITHUB_ENV"
- run: echo "Deploying $VERSION"   # now populated

Pick the right expansion for the context

  1. Use ${{ env.VAR }} for workflow expressions evaluated before the shell.
  2. Use $VAR (or %VAR% on cmd) inside a run script for shell-level expansion.
  3. Define static values once under a job or step env block.

How to prevent it

  • Use GITHUB_ENV (and GITHUB_OUTPUT) to pass values between steps.
  • Keep static configuration in a job-level env block.
  • Avoid mixing ${{ }} and $VAR for the same value in one command.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →