GitHub Foundations — Question 25

Which of the following commands will set the $FOO environment variable within a script, so that it may be used in subsequent workflow job steps?

Answer options

Correct answer: B

Explanation

The correct answer is B because it appends the variable assignment to the $GITHUB_ENV file, which is specifically designed for setting environment variables in GitHub Actions. Option A is outdated and not recommended, while option C uses incorrect syntax for setting an environment variable. Option D sets the variable only for the current shell session and does not persist it for later steps.