GitHub Actions Certification — Question 8

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 definition to the $GITHUB_ENV file, which is the proper method to set environment variables in GitHub Actions. Option A is outdated and no longer recommended, option C contains incorrect syntax, and option D sets the variable only for the current shell session, not for subsequent steps.