Skip to content

Commit fbab88a

Browse files
subatoiCopilotSiaraMistheiskr
authored
Scannability: 'Using secrets in GitHub Actions' article (#54261)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Siara <108543037+SiaraMist@users.noreply.github.com> Co-authored-by: Kevin Heis <heiskr@users.noreply.github.com>
1 parent db8dddf commit fbab88a

11 files changed

Lines changed: 67 additions & 57 deletions

File tree

content/actions/managing-workflow-runs-and-deployments/managing-deployments/managing-environments-for-deployment.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ Once custom deployment protection rules have been created and installed on a rep
126126

127127
## Environment secrets
128128

129-
Secrets stored in an environment are only available to workflow jobs that reference the environment. If the environment requires approval, a job cannot access environment secrets until one of the required reviewers approves it. For more information about secrets, see [AUTOTITLE](/actions/security-guides/using-secrets-in-github-actions).
129+
Secrets stored in an environment are only available to workflow jobs that reference the environment. If the environment requires approval, a job cannot access environment secrets until one of the required reviewers approves it. For more information about secrets, see [AUTOTITLE](/actions/security-for-github-actions/security-guides/about-secrets).
130130

131131
{% ifversion fpt %}
132132
> [!NOTE]

content/actions/migrating-to-github-actions/manually-migrating-to-github-actions/migrating-from-gitlab-cicd-to-github-actions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ For more information, see [AUTOTITLE](/actions/using-workflows/events-that-trigg
264264

265265
GitLab CI/CD and {% data variables.product.prodname_actions %} support setting variables in the pipeline or workflow configuration file, and creating secrets using the GitLab or {% data variables.product.github %} UI.
266266

267-
For more information, see [AUTOTITLE](/actions/learn-github-actions/variables) and [AUTOTITLE](/actions/security-guides/using-secrets-in-github-actions).
267+
For more information, see [AUTOTITLE](/actions/learn-github-actions/variables) and [AUTOTITLE](/actions/security-for-github-actions/security-guides/about-secrets).
268268

269269
## Caching
270270

content/actions/migrating-to-github-actions/manually-migrating-to-github-actions/migrating-from-travis-ci-to-github-actions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ When migrating from Travis CI, consider the following key features in {% data va
163163

164164
### Storing secrets
165165

166-
{% data variables.product.prodname_actions %} allows you to store secrets and reference them in your jobs. {% data variables.product.prodname_actions %} organizations can limit which repositories can access organization secrets. Deployment protection rules can require manual approval for a workflow to access environment secrets. For more information, see [AUTOTITLE](/actions/security-guides/using-secrets-in-github-actions).
166+
{% data variables.product.prodname_actions %} allows you to store secrets and reference them in your jobs. {% data variables.product.prodname_actions %} organizations can limit which repositories can access organization secrets. Deployment protection rules can require manual approval for a workflow to access environment secrets. For more information, see [AUTOTITLE](/actions/security-for-github-actions/security-guides/about-secrets).
167167

168168
### Sharing files between jobs and workflows
169169

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
title: About secrets
3+
intro: 'Learn about secrets as they''re used in GitHub Actions.'
4+
versions:
5+
fpt: '*'
6+
ghes: '*'
7+
ghec: '*'
8+
---
9+
10+
{% data reusables.actions.enterprise-github-hosted-runners %}
11+
12+
## About secrets
13+
14+
Secrets allow you to store sensitive information in your organization, repository, or repository environments. Secrets are variables that you create to use in {% data variables.product.prodname_actions %} workflows in an organization, repository, or repository environment.
15+
16+
{% data variables.product.prodname_actions %} can only read a secret if you explicitly include the secret in a workflow.
17+
18+
## Naming your secrets
19+
20+
>[!TIP]
21+
> To help ensure that {% data variables.product.prodname_dotcom %} redacts your secrets in logs correctly, avoid using structured data as the values of secrets.
22+
23+
The following rules apply to secret names:
24+
25+
{% data reusables.actions.actions-secrets-and-variables-naming %}
26+
27+
{% data reusables.codespaces.secret-precedence %} Similarly, if an organization, repository, and environment all have a secret with the same name, the environment-level secret takes precedence.
28+
29+
## Using your secrets in workflows
30+
31+
{% data reusables.actions.secrets-redaction-warning %}
32+
33+
{% data reusables.actions.secrets-org-level-overview %}
34+
35+
For environment secrets, you can enable required reviewers to control access to the secrets. A workflow job cannot access environment secrets until approval is granted by required approvers.
36+
37+
To make a secret available to an action, you must set the secret as an input or environment variable in your workflow file. Review the action's README file to learn about which inputs and environment variables the action expects. See [AUTOTITLE](/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsenv).
38+
39+
Organization and repository secrets are read when a workflow run is queued, and environment secrets are read when a job referencing the environment starts.
40+
41+
## Limiting credential permissions
42+
43+
When generating credentials, we recommend that you grant the minimum permissions possible. For example, instead of using personal credentials, use [deploy keys](/authentication/connecting-to-github-with-ssh/managing-deploy-keys#deploy-keys) or a service account. Consider granting read-only permissions if that's all that is needed, and limit access as much as possible.
44+
45+
When generating a {% data variables.product.pat_v1 %}, select the fewest scopes necessary. When generating a {% data variables.product.pat_v2 %}, select the minimum permissions and repository access required.
46+
47+
Instead of using a {% data variables.product.pat_generic %}, consider using a {% data variables.product.prodname_github_app %}, which uses fine-grained permissions and short lived tokens, similar to a {% data variables.product.pat_v2 %}. Unlike a {% data variables.product.pat_generic %}, a {% data variables.product.prodname_github_app %} is not tied to a user, so the workflow will continue to work even if the user who installed the app leaves your organization. For more information, see [AUTOTITLE](/apps/creating-github-apps/guides/making-authenticated-api-requests-with-a-github-app-in-a-github-actions-workflow).
48+
49+
## Further reading
50+
51+
* [AUTOTITLE](/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions)
52+
* [AUTOTITLE](/rest/actions/secrets)

content/actions/security-for-github-actions/security-guides/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ versions:
88
ghec: '*'
99
children:
1010
- /security-hardening-for-github-actions
11+
- /about-secrets
1112
- /using-secrets-in-github-actions
1213
- /automatic-token-authentication
1314
- /using-githubs-security-features-to-secure-your-use-of-github-actions

content/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions.md

Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -19,51 +19,7 @@ versions:
1919

2020
{% data reusables.actions.enterprise-github-hosted-runners %}
2121

22-
## About secrets
23-
24-
Secrets are variables that you create in an organization, repository, or repository environment. The secrets that you create are available to use in {% data variables.product.prodname_actions %} workflows. {% data variables.product.prodname_actions %} can only read a secret if you explicitly include the secret in a workflow.
25-
26-
{% data reusables.actions.secrets-org-level-overview %}
27-
28-
For secrets stored at the environment level, you can enable required reviewers to control access to the secrets. A workflow job cannot access environment secrets until approval is granted by required approvers.
29-
30-
> [!NOTE]
31-
> {% data reusables.actions.about-oidc-short-overview %}
32-
33-
### Naming your secrets
34-
35-
The following rules apply to secret names:
36-
37-
{% data reusables.actions.actions-secrets-and-variables-naming %}
38-
39-
For example, a secret created at the environment level must have a unique name in that environment, a secret created at the repository level must have a unique name in that repository, and a secret created at the organization level must have a unique name at that level.
40-
41-
{% data reusables.codespaces.secret-precedence %} Similarly, if an organization, repository, and environment all have a secret with the same name, the environment-level secret takes precedence.
42-
43-
To help ensure that {% data variables.product.prodname_dotcom %} redacts your secrets in logs correctly, avoid using structured data as the values of secrets. For example, avoid creating secrets that contain JSON or encoded Git blobs. Using structured data as secrets could cause non-secrets to be detected as such, making passing data between workflows harder to implement. In such cases, consider manipulating the structured data, for example encoding them to a string, before storing them as secrets, and decoding them before they are used.
44-
45-
### Accessing your secrets
46-
47-
To make a secret available to an action, you must set the secret as an input or environment variable in the workflow file. Review the action's README file to learn about which inputs and environment variables the action expects. For more information, see [AUTOTITLE](/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsenv).
48-
49-
You can use and read secrets in a workflow file if you have access to edit the file. For more information, see [AUTOTITLE](/get-started/learning-about-github/access-permissions-on-github).
50-
51-
{% data reusables.actions.secrets-redaction-warning %}
52-
53-
Organization and repository secrets are read when a workflow run is queued, and environment secrets are read when a job referencing the environment starts.
54-
55-
You can also manage secrets using the REST API. For more information, see [AUTOTITLE](/rest/actions/secrets).
56-
57-
### Limiting credential permissions
58-
59-
When generating credentials, we recommend that you grant the minimum permissions possible. For example, instead of using personal credentials, use [deploy keys](/authentication/connecting-to-github-with-ssh/managing-deploy-keys#deploy-keys) or a service account. Consider granting read-only permissions if that's all that is needed, and limit access as much as possible.
60-
61-
When generating a {% data variables.product.pat_v1 %}, select the fewest scopes necessary. When generating a {% data variables.product.pat_v2 %}, select the minimum permissions and repository access required.
62-
63-
Instead of using a {% data variables.product.pat_generic %}, consider using a {% data variables.product.prodname_github_app %}, which uses fine-grained permissions and short lived tokens, similar to a {% data variables.product.pat_v2 %}. Unlike a {% data variables.product.pat_generic %}, a {% data variables.product.prodname_github_app %} is not tied to a user, so the workflow will continue to work even if the user who installed the app leaves your organization. For more information, see [AUTOTITLE](/apps/creating-github-apps/guides/making-authenticated-api-requests-with-a-github-app-in-a-github-actions-workflow).
64-
65-
> [!NOTE]
66-
> Users with collaborator access to a repository can use the REST API to manage secrets for that repository, and users with admin access to an organization can use the REST API to manage secrets for that organization. For more information, see [AUTOTITLE](/rest/actions/secrets).
22+
For general information about secrets, see [AUTOTITLE](/actions/security-for-github-actions/security-guides/about-secrets).
6723

6824
## Creating secrets for a repository
6925

@@ -212,6 +168,7 @@ You can check which access policies are being applied to a secret in your organi
212168
> [!NOTE]
213169
> * {% data reusables.actions.forked-secrets %}
214170
> * Secrets are not automatically passed to reusable workflows. For more information, see [AUTOTITLE](/actions/using-workflows/reusing-workflows#passing-inputs-and-secrets-to-a-reusable-workflow).
171+
> {% data reusables.actions.about-oidc-short-overview %}
215172
216173
To provide an action with a secret as an input or environment variable, you can use the `secrets` context to access secrets you've created in your repository. For more information, see [AUTOTITLE](/actions/learn-github-actions/contexts) and [AUTOTITLE](/actions/using-workflows/workflow-syntax-for-github-actions).
217174

content/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ You can set a custom variable in two ways.
3030
* To define a configuration variable across multiple workflows, you can define it at the organization, repository, or environment level. For more information, see [Defining configuration variables for multiple workflows](#defining-configuration-variables-for-multiple-workflows).
3131

3232
> [!WARNING]
33-
> By default, variables render unmasked in your build outputs. If you need greater security for sensitive information, such as passwords, use secrets instead. For more information, see [AUTOTITLE](/actions/security-guides/using-secrets-in-github-actions).
33+
> By default, variables render unmasked in your build outputs. If you need greater security for sensitive information, such as passwords, use secrets instead. For more information, see [AUTOTITLE](/actions/security-for-github-actions/security-guides/about-secrets).
3434
3535
## Defining environment variables for a single workflow
3636

content/rest/actions/secrets.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ autogenerated: rest
1616

1717
## About secrets in {% data variables.product.prodname_actions %}
1818

19-
You can use the REST API to create, update, delete, and retrieve information about secrets that can be used in workflows in {% data variables.product.prodname_actions %}. {% data reusables.actions.about-secrets %} For more information, see [AUTOTITLE](/actions/security-guides/using-secrets-in-github-actions).
19+
You can use the REST API to create, update, delete, and retrieve information about secrets that can be used in workflows in {% data variables.product.prodname_actions %}. {% data reusables.actions.about-secrets %} For more information, see [AUTOTITLE](/actions/security-for-github-actions/security-guides/about-secrets).
2020

2121
<!-- Content after this section is automatically generated -->
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
* Names can only contain alphanumeric characters (`[a-z]`, `[A-Z]`, `[0-9]`) or underscores (`_`). Spaces are not allowed.
2-
* Names must not start with the `GITHUB_` prefix.
3-
* Names must not start with a number.
4-
* Names are case insensitive.
5-
* Names must be unique at the level they are created at.
1+
* Can only contain alphanumeric characters (`[a-z]`, `[A-Z]`, `[0-9]`) or underscores (`_`). Spaces are not allowed.
2+
* Must not start with the `GITHUB_` prefix.
3+
* Must not start with a number.
4+
* Are case insensitive.
5+
* Must be unique to the repository, organization, or enterprise where they are created.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
For secrets stored at the organization-level, you can use access policies to control which repositories can use organization secrets. Organization-level secrets let you share secrets between multiple repositories, which reduces the need for creating duplicate secrets. Updating an organization secret in one location also ensures that the change takes effect in all repository workflows that use that secret.
1+
Organization-level secrets let you share secrets between multiple repositories, which reduces the need for creating duplicate secrets. Updating an organization secret in one location also ensures that the change takes effect in all repository workflows that use that secret.

0 commit comments

Comments
 (0)