[GitHub Actions] Share an environment variable between steps

Created on November 30, 2026

Append NAME=value to the file at $GITHUB_ENV to set an environment variable for later steps in the same job. The step that writes the file cannot read the new value through its environment yet.

steps:
  - name: Set STAGE
    run: echo "STAGE=dev" >> "$GITHUB_ENV"
  - name: Print STAGE
    run: echo "$STAGE"

The second step prints dev.

GitHub Actions