Using environment variables
GitHub sets default environment variables for each GitHub Actions workflow run. You can also set custom environment variables in your workflow file.
GitHub Actions is available with GitHub Free, GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub One. GitHub Actions is not available for private repositories owned by accounts using legacy per-repository plans. For more information, see "GitHub's products."
About environment variables
GitHub sets default environment variables that are available to every step in a workflow run. Environment variables are case-sensitive. Commands run in actions or steps can create, read, and modify environment variables.
To set custom environment variables, you need to specify the variables in the workflow file. You can define environment variables for a step, job, or entire workflow using the jobs.<job_id>.steps.env, jobs.<job_id>.env, and env keywords. Para obtener más información, consulta "Sintaxis del flujo de trabajo para GitHub".
steps:
- name: Hello world
run: echo Hello world $FIRST_NAME $middle_name $Last_Name!
env:
FIRST_NAME: Mona
middle_name: The
Last_Name: Octocat
You can also use the set-env workflow command to set an environment variable that the following steps in a workflow can use. The set-env command can be used directly by an action or as a shell command in a workflow file using the run keyword. For more information, see "Workflow commands for GitHub Actions."
Variables de entorno predeterminadas
We strongly recommend that actions use environment variables to access the filesystem rather than using hardcoded file paths. GitHub sets environment variables for actions to use in all runner environments.
| Variable de entorno | Descripción |
|---|---|
HOME | La ruta al directorio de inicio GitHub utilizado para almacenar datos de usuario. Por ejemplo, /github/home. |
GITHUB_WORKFLOW | El nombre del flujo de trabajo. |
GITHUB_RUN_ID | A unique number for each run within a repository. This number does not change if you re-run the workflow run. |
GITHUB_RUN_NUMBER | A unique number for each run of a particular workflow in a repository. This number begins at 1 for the workflow's first run, and increments with each new run. This number does not change if you re-run the workflow run. |
GITHUB_ACTION | El único identificador (id) de la acción. |
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 | El nombre de la persona o de la app que inició el flujo de trabajo. Por ejemplo, octocat. |
GITHUB_REPOSITORY | El nombre del repositorio y del propietario. Por ejemplo, octocat/Hello-World. |
GITHUB_EVENT_NAME | El nombre del evento webhook que activó el flujo de trabajo |
GITHUB_EVENT_PATH | La ruta del archivo con la carga completa del evento webhook. Por ejemplo, /github/workflow/event.json. |
GITHUB_WORKSPACE | La ruta del directorio del espacio de trabajo GitHub. El directorio del espacio de trabajo contiene un subdirectorio con una copia de tu repositorio si tu flujo de trabajo usa la acción actions/checkout. Si no usas la acción actions/checkout, el directorio estará vacío. Por ejemplo, /home/runner/work/my-repo-name/my-repo-name. |
GITHUB_SHA | El SHA de confirmación que activó el flujo de trabajo. Por ejemplo, ffac537e6cbbf934b08745a378932722df287a53. |
GITHUB_REF | La rama o ref de etiqueta que activó el flujo de trabajo. Por ejemplo, refs/heads/feature-branch-1. Si no hay una rama o etiqueta disponible para el tipo de evento, la variable no existirá. |
GITHUB_HEAD_REF | Solo establecida para los repositorios bifurcados. La rama del repositorio encabezado. |
GITHUB_BASE_REF | Solo establecida para los repositorios bifurcados. La rama del repositorio base. |
Naming conventions for environment variables
Note: GitHub reserves the GITHUB_ environment variable prefix for internal use by GitHub. Configurar una variable de entorno o secreto con el prefijo GITHUB_ dará como resultado un error.
Toda variable de entorno nueva que configures que apunte a una ubicación en el sistema de archivos debe tener un sufijo _PATH. Las variables predeterminadas HOME y GITHUB_WORKSPACE son excepciones a esta convención, porque las palabras "home" y "workspace" ya implican una ubicación.

