About secrets
Secrets allow you to store sensitive information in your organization, repository, or repository environments. Secrets are variables that you create to use in GitHub Actions workflows in an organization, repository, or repository environment.
GitHub Actions can only read a secret if you explicitly include the secret in a workflow.
Naming your secrets
Tip
To help ensure that GitHub redacts your secrets in logs correctly, avoid using structured data as the values of secrets.
The following rules apply to secret names:
- Имена могут содержать только буквенно-цифровые символы (
[a-z]
,[A-Z]
,[0-9]
) или символы подчеркивания (_
). Пробелы недопустимы. - Имена не должны начинаться с префикса
GITHUB_
. - Имена не должны начинаться с числа.
- В именах учитывается регистр.
- Имена должны быть уникальными на уровне, на который они создаются.
Если секрет с одним и тем же именем существует на нескольких уровнях, приоритет имеет секрет самого низкого уровня. Например, если секрет уровня организации имеет то же имя, что и секрет уровня репозитория, то приоритет имеет секрет уровня репозитория. Similarly, if an organization, repository, and environment all have a secret with the same name, the environment-level secret takes precedence.
Using your secrets in workflows
Warning
Если секрет использовался в задании, GitHub автоматически редактирует секреты, напечатанные в журнале. Не следует намеренно печатать секреты в журнале.
В случае с секретами, хранящимися на уровне организации, можно использовать политики доступа для управления тем, какие репозитории могут использовать секреты организации. Секреты уровня организации позволяют совместно использовать секреты в нескольких репозиториях, что снижает потребность в создании повторяющихся секретов. При обновлении секрета организации в одном расположении это изменение вступает в силу во всех рабочих процессах репозитория, использующих этот секрет.
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.
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 Синтаксис рабочего процесса для GitHub Actions.
Organization and repository secrets are read when a workflow run is queued, and environment secrets are read when a job referencing the environment starts.
Limiting credential permissions
When generating credentials, we recommend that you grant the minimum permissions possible. For example, instead of using personal credentials, use 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.
When generating a personal access token (classic), select the fewest scopes necessary. When generating a fine-grained personal access token, select the minimum permissions and repository access required.
Instead of using a personal access token, consider using a GitHub App, which uses fine-grained permissions and short lived tokens, similar to a fine-grained personal access token. Unlike a personal access token, a 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 Выполнение запросов API с проверкой подлинности с помощью приложения GitHub в рабочем процессе GitHub Actions.