How do `$GITHUB_ENV` and `$GITHUB_PATH` work, and when does a value become visible?
BeginnerConceptContexts, Expressions, Env & Outputs
Answer
Lines appended to $GITHUB_ENV become environment variables in subsequent steps of the same job, not the current step. Lines appended to $GITHUB_PATH are prepended to PATH for subsequent steps.
echo "IMAGE_TAG=sha-${GITHUB_SHA::7}" >> "$GITHUB_ENV"
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
In the same step, also export IMAGE_TAG=... if you need it right away. Never write untrusted data to GITHUB_ENV: a newline lets an attacker set arbitrary variables.
More on Contexts, Expressions, Env & Outputs
List the available contexts and what each holds.BeginnerWhich contexts can you use in which keys? Give two examples that trip people up.AdvancedWhat are the expression operators and how do comparisons coerce types?IntermediateHow do you write a ternary in GitHub Actions expressions?IntermediateWhat do `contains`, `startsWith`, `endsWith`, `format` and `join` do?BeginnerWhat are object filters (`.*`) and how are they useful?Intermediate