nerdexam
GitHub

GITHUB-ACTIONS · Question #51

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?

The correct answer is B. run: echo "FOO=bar" >> $GITHUB_ENV. The $GITHUB_ENV environment variable is used to set environment variables that persist across steps in a workflow job. By echoing FOO=bar into $GITHUB_ENV, the variable FOO will be available in subsequent steps within the same job.

GitHub Actions - Workflow Commands

Question

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?

Options

  • Arun: echo "::set-env name=FOO::bar"
  • Brun: echo "FOO=bar" >> $GITHUB_ENV
  • Crun: echo ${{ $FOO=bar }}
  • Drun: export FOO=bar

How the community answered

(35 responses)
  • B
    91% (32)
  • C
    3% (1)
  • D
    6% (2)

Explanation

The $GITHUB_ENV environment variable is used to set environment variables that persist across steps in a workflow job. By echoing FOO=bar into $GITHUB_ENV, the variable FOO will be available in subsequent steps within the same job.

Topics

#environment variables#GITHUB_ENV#workflow commands#step outputs

Community Discussion

No community discussion yet for this question.

Full GITHUB-ACTIONS Practice