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.
No se puede sobrescribir el valor de las variables de entorno predeterminadas GITHUB_*
y RUNNER_*
. Actualmente, se puede sobrescribir el valor de la variable CI
. Sin embargo, no se garantiza que sea posible siempre. For more information about setting environment variables, see Almacenamiento de información en variables and Comandos de flujo de trabajo para Acciones de GitHub.
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 | El id. de cuenta de la persona o aplicación que desencadenó la ejecución inicial del flujo de trabajo. Por ejemplo, 1234567 . Ten en cuenta que es diferente del nombre de usuario del actor. |
GITHUB_API_URL | Returns the API URL. For example: http(s)://HOSTNAME/api/v3 . |
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 flujo de trabajo para Acciones de GitHub. |
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: http(s)://HOSTNAME/api/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 flujo de trabajo para Acciones de GitHub. |
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 flujo de trabajo para Acciones de GitHub. |
GITHUB_REF | Referencia de formato completo de la rama o etiqueta que desencadenó la ejecución del flujo de trabajo. En el caso de los flujos de trabajo desencadenados por push , se trata de la rama o la etiqueta ref que se insertó. En el caso de los flujos de trabajo desencadenados por pull_request , se trata de la rama de combinación de solicitudes de incorporación de cambios. En el caso de los flujos de trabajo desencadenados por release , se trata de la etiqueta de versión creada. Para otros desencadenadores, se trata de la rama o la etiqueta ref que desencadenó la ejecución del flujo de trabajo. Esto solo se configura si una rama o etiqueta se encuentra disponible para el tipo de evento. La etiqueta ref especificada tiene el formato completo, lo que significa que para las ramas el formato es refs/heads/<branch_name> . En el caso de los eventos de solicitud de incorporación de cambios excepto pull_request_target , es refs/pull/<pr_number>/merge . pull_request_target eventos tienen ref de la rama base. Para las etiquetas, es refs/tags/<tag_name> . Por ejemplo, refs/heads/feature-branch-1 . |
GITHUB_REF_NAME | Nombre de referencia corto de la rama o etiqueta que desencadenó la ejecución del flujo de trabajo. Este valor coincide con el nombre de la rama o etiqueta que se muestra en GitHub. Por ejemplo, feature-branch-1 .En el caso de las solicitudes de incorporación de cambios, el formato es <pr_number>/merge . |
GITHUB_REF_PROTECTED | true si las protecciones de rama están configurados para la referencia que desencadenó la ejecución del flujo de trabajo. |
GITHUB_REF_TYPE | El tipo de ref que activó la ejecución de flujo de trabajo. Los valores válidos son branch y tag . |
GITHUB_REPOSITORY | The owner and repository name. For example, octocat/Hello-World . |
GITHUB_REPOSITORY_ID | El id. del repositorio. Por ejemplo, 123456789 . Ten en cuenta que esto es diferente del nombre del repositorio. |
GITHUB_REPOSITORY_OWNER | The repository owner's name. For example, octocat . |
GITHUB_REPOSITORY_OWNER_ID | Id. de cuenta del propietario del repositorio. Por ejemplo, 1234567 . Tenga en cuenta que es diferente del nombre del propietario. |
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 | Un número único para cada ejecución de flujo de trabajo dentro de un repositorio. Este número no cambia si vuelves a ejecutar el flujo de trabajo. For example, 1658821493 . |
GITHUB_RUN_NUMBER | Un número único para cada ejecución de un flujo de trabajo particular en un repositorio. Este número comienza por 1 para la primera ejecución del flujo de trabajo y aumenta con cada nueva ejecución. Este número no cambia si vuelves a ejecutar el flujo de trabajo. For example, 3 . |
GITHUB_SERVER_URL | The URL of the GitHub server. For example: https://HOSTNAME . |
GITHUB_SHA | El SHA de confirmación que activó el flujo de trabajo. El valor de este SHA de confirmación depende del evento que activó el flujo de trabajo. Para más información, consulta Events that trigger workflows. Por ejemplo, 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 flujo de trabajo para Acciones de GitHub. |
GITHUB_TRIGGERING_ACTOR | Nombre de usuario del usuario que inició la ejecución del flujo de trabajo. Si la ejecución del flujo de trabajo es una repetición, este valor puede ser distinto de github.actor . Todas las repeticiones de ejecución de flujo de trabajo usarán los privilegios de github.actor , incluso si el actor que inicia la repetición de la ejecución (github.triggering_actor ) tiene otros privilegios. |
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 | La ruta de acceso de referencia al flujo de trabajo. Por ejemplo, octocat/hello-world/.github/workflows/my-workflow.yml@refs/heads/my_branch . |
GITHUB_WORKFLOW_SHA | El SHA de confirmación para el archivo de flujo de trabajo. |
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 | La arquitectura del ejecutor que ejecuta el job. Los valores posibles son X86 , X64 , ARM o ARM64 . |
RUNNER_DEBUG | Esto solo se establece si el registro de depuración está habilitado y siempre tiene el valor de 1 . Puede ser útil como indicador para habilitar la depuración adicional o el registro detallado en tus propios pasos de trabajo. |
RUNNER_ENVIRONMENT | El entorno del ejecutor que ejecuta el trabajo. Los valores posibles son: github-hosted para los ejecutores hospedados en GitHub proporcionados por GitHub y self-hosted para los ejecutores de prueba interna configurados por el propietario del repositorio. |
RUNNER_NAME | El nombre del ejecutor que ejecuta el job. Este nombre puede no ser único en una ejecución de flujo de trabajo como ejecutores en el repositorio y los niveles de organización podrían usar el mismo nombre. For example, Hosted Agent |
RUNNER_OS | El sistema operativo del ejecutor que ejecuta el trabajo. Los valores posibles son Linux , Windows o macOS . For example, Windows |
RUNNER_TEMP | La ruta a un directorio temporal en el ejecutor. Este directorio se vacía al inicio y al final de cada job. Nota que los archivos no se eliminarán si la cuenta de usuario del ejecutor no tiene permisos para borrarlos. For example, D:\a\_temp |
RUNNER_TOOL_CACHE | La ruta al directorio que contiene las herramientas preinstaladas para los ejecutores hospedados en GitHub. Para más información, consulta Utilizar los ejecutores hospedados en GitHub. For example, C:\hostedtoolcache\windows |
Nota:
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:
- Solo puede contener caracteres alfanuméricos (
[a-z]
,[A-Z]
,[0-9]
) o caracteres de subrayado (_
). No se permiten espacios. - No debe comenzar con el prefijo
GITHUB_
. - No puede iniciar con un número.
- No distinguen entre mayúsculas y minúsculas cuando se hace referencia a ellos. GitHub almacena nombres secretos en mayúsculas independientemente de cómo se escriban.
- Debe ser único para el repositorio, la organización o la empresa donde se crean.
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.
Nota:
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 10 MB 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 10 MB. If the total size of repository variables exceeds 10 MB, 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 10 MB. If the total combined size of organization and repository variables exceeds 10 MB, 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.
Nota:
Environment-level variables do not count toward the 10 MB 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.
Advertencia
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 }} |