Skip to main content

此版本的 GitHub Enterprise Server 已于以下日期停止服务 2025-06-19. 即使针对重大安全问题,也不会发布补丁。 为了获得更好的性能、更高的安全性和新功能,请升级到最新版本的 GitHub Enterprise。 如需升级帮助,请联系 GitHub Enterprise 支持

Variables

Learn about variables in GitHub Actions workflows.

About

Variables provide a way to store and reuse non-sensitive configuration information. You can store any configuration data such as compiler flags, usernames, or server names as variables. Variables are interpolated on the runner machine that runs your workflow. Commands that run in actions or workflow steps can create, read, and modify variables.

You can set your own custom variables or use the default environment variables that GitHub sets automatically.

You can set a custom variable in two ways.

  • To define an environment variable for use in a single workflow, you can use the env key in the workflow file. For more information, see Defining environment variables for a single workflow.
  • To define a configuration variable across multiple workflows, you can define it at the organization, repository, or environment level. When creating a variable in an organization, you can use a policy to limit access by repository. For example, you can grant access to all repositories, or limit access to only private repositories or a specified list of repositories. For more information, see Defining configuration variables for multiple workflows.

警告

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 Secrets.

For reference documentation, see Variables reference.