Secrets are not environment variables

Carlos Quintero 120 Reputation points
2024-07-13T15:24:44.7233333+00:00

In page https://learn.microsoft.com/en-us/training/modules/manage-github-actions-enterprise/manage-encrypted-secrets

it states that

Secrets are encrypted environment variables you can create to...

and in knowledge check https://learn.microsoft.com/en-us/training/modules/manage-github-actions-enterprise/knowledge-check

the question "What are encrypted secrets?" is provided with the answer:

Encrypted secrets are encrypted environment variables you can create to store sensitive information.

Both are incorrect. Secrets are variables that are accessed through the secrets context. They are NOT environment variables.

See the official documentation: https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions

Secrets are variables that you create ...

Notice that is says "variables", not "environment variables".

If you want an environment variable with a secret, you must create such environment variable with an "env" section, define a name for the environment variable and assign to it the value of the secrets context:

steps:
  - name: Hello world action
    ...
    env:
      super_secret: ${{ secrets.SuperSecret }}

This question is related to the following Learning Module

GitHub Training
GitHub Training
GitHub: A web-based hosting service for software development and version control using Git. Acquired by Microsoft in 2018.Training: Instruction to develop new skills.
41 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.