Secrets are not environment variables

Carlos Quintero 245 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.
46 questions
{count} votes

Accepted answer
  1. Rakesh Gurram 9,065 Reputation points Microsoft Vendor
    2024-10-03T11:39:10.4433333+00:00

    Hi Carlos Quintero,

    Thanks for bringing this to our notice.

    Our team is aware of this issue and is actively working on a solution.

    In the meantime, we ask that you complete the Learning Paths without the exercise modules. We will provide updates as soon as we have more information.

    Thank you for your patience and understanding.

    0 comments No comments

0 additional answers

Sort by: Most helpful

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.