GH-200 · Question #93
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. Variables set in GITHUB_ENV apply only to the…
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
(66 responses)- A5% (3)
- B83% (55)
- C9% (6)
- D3% (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. Variables set in GITHUB_ENV apply only to the current job. echo "PR_NUMBER=$pr_number" >> $GITHUB_ENV https://github.com/orgs/community/discussions/56849
Topics
Community Discussion
No community discussion yet for this question.