nerdexam
GitHub

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.

Use secrets and environment variables

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)
  • A
    3% (1)
  • B
    8% (3)
  • C
    73% (27)
  • D
    16% (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

#encrypted secrets#if conditionals#secrets context#workflow expressions

Community Discussion

No community discussion yet for this question.

Full GITHUB-ACTIONS Practice