What is the 'GITHUB_ENV' file used for in GitHub Actions?
Select an answer to reveal the explanation.
Short Explanation and Infographic
GITHUB_ENV is how steps in the same job talk to each other through environment variables. Write 'MY_VAR=value' to the GITHUB_ENV file and every subsequent step in that job can use $MY_VAR as an environment variable.
Full explanation below image
Full Explanation
In GitHub Actions, the GITHUB_ENV file is a mechanism for workflow steps to set environment variables that persist to subsequent steps within the same job. To set a variable, a step writes to the file at the path specified by the $GITHUB_ENV environment variable using the format 'VARIABLE_NAME=value'. Example: 'echo "VERSION=1.2.3" >> $GITHUB_ENV'. After that step, the variable $VERSION is available in all subsequent steps of the same job. This is different from: (1) Step outputs (used to pass values to other jobs), (2) secrets (stored in GitHub settings, not runtime), (3) The workflow-level 'env:' block (static, defined in YAML). GITHUB_ENV allows dynamic, runtime-computed values to flow between steps.