GITHUB-ACTIONS · Question #73
How can GitHub Actions encrypted secrets be used in if: conditionals within a workflow job?
The correct answer is C. Use the secrets context within the conditional statement, e.g. ${{ secrets.MySuperSecret }}.. GitHub Actions encrypted secrets can be accessed in workflows using the secrets context. You can directly reference the secret within an if: conditional using ${{ secrets.MySuperSecret }} to determine whether a job or step should run based on the secret's value.
Question
How can GitHub Actions encrypted secrets be used in if: conditionals within a workflow job?
Options
- ASet the encrypted secret as a job-level environment variable and then reference the environment
- BCreate a job dependency that exposes the encrypted secret as a job output, which can then be
- CUse the secrets context within the conditional statement, e.g. ${{ secrets.MySuperSecret }}.
- DUse a workflow command to expose the encrypted secret via a step's output parameter and then
How the community answered
(37 responses)- A3% (1)
- B8% (3)
- C73% (27)
- D16% (6)
Explanation
GitHub Actions encrypted secrets can be accessed in workflows using the secrets context. You can directly reference the secret within an if: conditional using ${{ secrets.MySuperSecret }} to determine whether a job or step should run based on the secret's value.
Topics
Community Discussion
No community discussion yet for this question.