This article lists the supported variables you can use in GitHub Actions workflows, including environment variables, configuration variables, and default variables provided by GitHub. Use this reference to look up variable names, naming conventions, limits, and supported contexts when configuring your workflows.
For more information about variables, see Variables.
Default environment variables
The default environment variables that GitHub sets are available to every step in a workflow.
Because default environment variables are set by GitHub and not defined in a workflow, they are not accessible through the env
context. However, most of the default variables have a corresponding, and similarly named, context property. For example, the value of the GITHUB_REF
variable can be read during workflow processing using the ${{ github.ref }}
context property.
Não é possível substituir o valor das variáveis de ambiente padrão chamadas GITHUB_*
e RUNNER_*
. Atualmente, você pode substituir o valor da variável CI
. No entanto, não é garantido que isso sempre será possível. For more information about setting environment variables, see Armazenar informações em variáveis and Comandos de fluxo de trabalho para o GitHub Actions.
We strongly recommend that actions use variables to access the filesystem rather than using hardcoded file paths. GitHub sets variables for actions to use in all runner environments.
Variable | Description |
---|---|
CI | Always set to true . |
GITHUB_ACTION | The name of the action currently running, or the id of a step. For example, for an action, __repo-owner_name-of-action-repo .GitHub removes special characters, and uses the name __run when the current step runs a script without an id . If you use the same script or action more than once in the same job, the name will include a suffix that consists of the sequence number preceded by an underscore. For example, the first script you run will have the name __run , and the second script will be named __run_2 . Similarly, the second invocation of actions/checkout will be actionscheckout2 . |
GITHUB_ACTION_PATH | The path where an action is located. This property is only supported in composite actions. You can use this path to change directories to where the action is located and access other files in that same repository. For example, /home/runner/work/_actions/repo-owner/name-of-action-repo/v1 . |
GITHUB_ACTION_REPOSITORY | For a step executing an action, this is the owner and repository name of the action. For example, actions/checkout . |
GITHUB_ACTIONS | Always set to true when GitHub Actions is running the workflow. You can use this variable to differentiate when tests are being run locally or by GitHub Actions. |
GITHUB_ACTOR | The name of the person or app that initiated the workflow. For example, octocat . |
GITHUB_ACTOR_ID | A ID da conta da pessoa ou do aplicativo que disparou a execução inicial do fluxo de trabalho. Por exemplo, 1234567 . Observe que isso é diferente do nome de usuário do ator. |
GITHUB_API_URL | Returns the API URL. For example: https://api.github.com . |
GITHUB_BASE_REF | The name of the base ref or target branch of the pull request in a workflow run. This is only set when the event that triggers a workflow run is either pull_request or pull_request_target . For example, main . |
GITHUB_ENV | The path on the runner to the file that sets variables from workflow commands. The path to this file is unique to the current step and changes for each step in a job. For example, /home/runner/work/_temp/_runner_file_commands/set_env_87406d6e-4979-4d42-98e1-3dab1f48b13a . For more information, see Comandos de fluxo de trabalho para o GitHub Actions. |
GITHUB_EVENT_NAME | The name of the event that triggered the workflow. For example, workflow_dispatch . |
GITHUB_EVENT_PATH | The path to the file on the runner that contains the full event webhook payload. For example, /github/workflow/event.json . |
GITHUB_GRAPHQL_URL | Returns the GraphQL API URL. For example: https://api.github.com/graphql . |
GITHUB_HEAD_REF | The head ref or source branch of the pull request in a workflow run. This property is only set when the event that triggers a workflow run is either pull_request or pull_request_target . For example, feature-branch-1 . |
GITHUB_JOB | The job_id of the current job. For example, greeting_job . |
GITHUB_OUTPUT | The path on the runner to the file that sets the current step's outputs from workflow commands. The path to this file is unique to the current step and changes for each step in a job. For example, /home/runner/work/_temp/_runner_file_commands/set_output_a50ef383-b063-46d9-9157-57953fc9f3f0 . For more information, see Comandos de fluxo de trabalho para o GitHub Actions. |
GITHUB_PATH | The path on the runner to the file that sets system PATH variables from workflow commands. The path to this file is unique to the current step and changes for each step in a job. For example, /home/runner/work/_temp/_runner_file_commands/add_path_899b9445-ad4a-400c-aa89-249f18632cf5 . For more information, see Comandos de fluxo de trabalho para o GitHub Actions. |
GITHUB_REF | A ref totalmente formada do branch ou tag que acionou a execução do fluxo de trabalho. Para fluxos de trabalho disparados por push , esse é o branch ou a ref da tag que foi enviada por push. Para fluxos de trabalho disparados por pull_request , esse é o branch de mesclagem de solicitação de pull. Para fluxos de trabalho disparados por release , essa é a tag de versão criada. Para outros gatilhos, esse é o branch ou a ref de tag que disparou a execução do fluxo de trabalho. Essa variável só é definida quando há um branch ou uma tag disponível para o tipo de evento. A ref fornecida tem o formato completo, o que significa que, para branches, o formato é refs/heads/<branch_name> . Para eventos de pull request, exceto por pull_request_target , é refs/pull/<pr_number>/merge . Eventos pull_request_target têm o ref do branch base. Para tags, é refs/tags/<tag_name> . Por exemplo, refs/heads/feature-branch-1 . |
GITHUB_REF_NAME | O nome de ref curto do branch ou tag que acionou a execução do fluxo de trabalho. Esse valor corresponde ao nome do branch ou tag mostrado em GitHub. Por exemplo, feature-branch-1 .Para solicitações de pull, o formato é <pr_number>/merge . |
GITHUB_REF_PROTECTED | true se proteções de ramificação ou conjuntos de regras estiverem configurados para a referência que disparou a execução do fluxo de trabalho. |
GITHUB_REF_TYPE | O tipo de ref que acionou a execução do fluxo de trabalho. Os valores válidos são branch ou tag . |
GITHUB_REPOSITORY | The owner and repository name. For example, octocat/Hello-World . |
GITHUB_REPOSITORY_ID | A ID do repositório. Por exemplo, 123456789 . Observe que isso é diferente do nome do repositório. |
GITHUB_REPOSITORY_OWNER | The repository owner's name. For example, octocat . |
GITHUB_REPOSITORY_OWNER_ID | A ID da conta do proprietário do repositório. Por exemplo, 1234567 . Observe que isso é diferente do nome do proprietário. |
GITHUB_RETENTION_DAYS | The number of days that workflow run logs and artifacts are kept. For example, 90 . |
GITHUB_RUN_ATTEMPT | A unique number for each attempt of a particular workflow run in a repository. This number begins at 1 for the workflow run's first attempt, and increments with each re-run. For example, 3 . |
GITHUB_RUN_ID | Um número exclusivo para cada fluxo de trabalho executado em um repositório. Este número não muda se você executar novamente o fluxo de trabalho. For example, 1658821493 . |
GITHUB_RUN_NUMBER | Um número exclusivo para cada execução de um fluxo de trabalho específico em um repositório. Esse número começa em 1 para a primeira execução do fluxo de trabalho e é incrementado a cada nova operação. Este número não muda se você executar novamente o fluxo de trabalho. For example, 3 . |
GITHUB_SERVER_URL | The URL of the GitHub server. For example: https://github.com . |
GITHUB_SHA | O commit SHA que acionou o fluxo de trabalho. O valor do commit deste SHA depende do evento que acionou o fluxo de trabalho. Para saber mais, confira Eventos que disparam fluxos de trabalho. Por exemplo, ffac537e6cbbf934b08745a378932722df287a53 . |
GITHUB_STEP_SUMMARY | The path on the runner to the file that contains job summaries from workflow commands. The path to this file is unique to the current step and changes for each step in a job. For example, /home/runner/_layout/_work/_temp/_runner_file_commands/step_summary_1cb22d7f-5663-41a8-9ffc-13472605c76c . For more information, see Comandos de fluxo de trabalho para o GitHub Actions. |
GITHUB_TRIGGERING_ACTOR | O nome de usuário de quem iniciou a execução do fluxo de trabalho. Se a execução do fluxo de trabalho for executada novamente, esse valor poderá ser diferente de github.actor . Qualquer nova execução de fluxo de trabalho usará os privilégios de github.actor , mesmo que o ator que inicie a nova execução (github.triggering_actor ) tenha privilégios diferentes. |
GITHUB_WORKFLOW | The name of the workflow. For example, My test workflow . If the workflow file doesn't specify a name , the value of this variable is the full path of the workflow file in the repository. |
GITHUB_WORKFLOW_REF | O caminho de referência para o fluxo de trabalho. Por exemplo, octocat/hello-world/.github/workflows/my-workflow.yml@refs/heads/my_branch . |
GITHUB_WORKFLOW_SHA | O SHA de commit para o arquivo de fluxo de trabalho. |
GITHUB_WORKSPACE | The default working directory on the runner for steps, and the default location of your repository when using the checkout action. For example, /home/runner/work/my-repo-name/my-repo-name . |
RUNNER_ARCH | A arquitetura do executor que está executando o trabalho. Os valores possíveis são X86 , X64 , ARM ou ARM64 . |
RUNNER_DEBUG | Isso será definido somente se o log de depuração estiver habilitado e sempre tiver o valor de 1 . Pode ser útil como um indicador para habilitar a depuração adicional ou o log detalhado em suas etapas de trabalho. |
RUNNER_ENVIRONMENT | O ambiente do executor que realiza a tarefa. Os valores possíveis são: github-hosted para executores hospedados no GitHub fornecidos pelo GitHub e self-hosted para executores auto-hospedados configurados pelo proprietário do repositório. |
RUNNER_NAME | O nome do executor que executa a tarefa. Esse nome pode não ser exclusivo em uma execução de fluxo de trabalho, pois os executores nos níveis de repositório e organização podem usar o mesmo nome. For example, Hosted Agent |
RUNNER_OS | O sistema operacional do executor que está executando o trabalho. Os valores possíveis são Linux , Windows , ou macOS . For example, Windows |
RUNNER_TEMP | O caminho para um diretório temporário no executor. Este diretório é esvaziado no início e no final de cada trabalho. Observe que os arquivos não serão removidos se a conta de usuário do executor não tiver permissão para excluí-los. For example, D:\a\_temp |
RUNNER_TOOL_CACHE | O caminho para o diretório que contém ferramentas pré-instaladas para executores hospedados em GitHub. Para saber mais, confira Usar executores hospedados no GitHub. For example, C:\hostedtoolcache\windows |
Observação
If you need to use a workflow run's URL from within a job, you can combine these variables: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID
Naming conventions for configuration variables
The following rules apply to configuration variable names:
- Só pode conter caracteres alfanuméricos (
[a-z]
,[A-Z]
,[0-9]
) ou sublinhados (_
). Espaços não são permitidos. - Não precisa começar com o prefixo
GITHUB_
. - Não precisa começar com um número.
- Não diferenciam maiúsculas de minúsculas quando referenciados. GitHub armazena nomes secretos como maiúsculas, independentemente de como eles são inseridos.
- Deve ser exclusivo para o repositório, a organização ou a empresa em que são criados.
Naming conventions for environment variables
When you set an environment variable, you cannot use any of the default environment variable names. For a complete list of default environment variables, see Variables reference below. If you attempt to override the value of one of these default variables, the assignment is ignored.
Observação
You can list the entire set of environment variables that are available to a workflow step by using run: env
in a step and then examining the output for the step.
Configuration variable precedence
If a variable with the same name exists at multiple levels, the variable at the lowest level takes precedence. For example, if an organization-level variable has the same name as a repository-level variable, then the repository-level variable takes precedence. Similarly, if an organization, repository, and environment all have a variable with the same name, the environment-level variable takes precedence.
For reusable workflows, the variables from the caller workflow's repository are used. Variables from the repository that contains the called workflow are not made available to the caller workflow.
Limits for configuration variables
Individual variables are limited to 48 KB in size.
You can store up to 1,000 organization variables, 500 variables per repository, and 100 variables per environment. The total combined size limit for organization and repository variables is 256 KB per workflow run.
A workflow created in a repository can access the following number of variables:
- Up to 500 repository variables, if the total size of repository variables is less than 256 KB. If the total size of repository variables exceeds 256 KB, only the repository variables that fall below the limit will be available (as sorted alphabetically by variable name).
- Up to 1,000 organization variables, if the total combined size of repository and organization variables is less than 256 KB. If the total combined size of organization and repository variables exceeds 256 KB, only the organization variables that fall below that limit will be available (after accounting for repository variables and as sorted alphabetically by variable name).
- Up to 100 environment-level variables.
Observação
Environment-level variables do not count toward the 256 KB total size limit. If you exceed the combined size limit for repository and organization variables and still need additional variables, you can use an environment and define additional variables in the environment.
Supported contexts
You will commonly use either the env
or github
context to access variable values in parts of the workflow that are processed before jobs are sent to runners.
Aviso
Do not print the github
context to logs. It contains sensitive information.
Context | Use case | Example |
---|---|---|
env | Reference custom variables defined in the workflow. | ${{ env.MY_VARIABLE }} |
github | Reference information about the workflow run and the event that triggered the run. | ${{ github.repository }} |