|
| 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) |
0 commit comments