GitHub Actions environment variables and scope
Variable scope
A variable’s location determines which steps can use it. GitHub’s variable guide distinguishes workflow, job and step env definitions, along with expressions evaluated before work reaches a runner.
Suppose a fictional report job uses REGION=west while one step overrides it with REGION=east. Trace the value for that step and then for the next one. A narrow override should not become a permanent workflow-wide change.
Shells and later steps
${{ env.REGION }} is an expression reference. $REGION is shell syntax on a compatible shell. Moving a shell expression into a workflow field processed before the runner won’t make it evaluate there.
A value written through an environment file is for later steps; it doesn’t retroactively rewrite the environment of the command that wrote it. For cross-job values, practice job outputs.
The local model implements selected variable and expression behavior. It doesn’t execute every shell or reproduce a hosted runner’s full process environment.