Frecuentemente publicamos actualizaciones de nuestra documentación. Es posible que la traducción de esta página esté en curso. Para conocer la información más actual, visita la documentación en inglés. Si existe un problema con las traducciones en esta página, por favor infórmanos.

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 se encuentra disponible con GitHub Free, GitHub Pro, GitHub Free para organizaciones, GitHub Team, GitHub Enterprise Cloud, y GitHub One. GitHub Actions no se encuentra disponible para repositorios privados que pertenezcan a cuentas que utilicen planes tradicionales por repositorio. Para obtener más información, consulta la sección "Productos de GitHub".

En este artículo

¿Te ayudó este documento?

Help us make these docs great!

All GitHub docs are open source. See something that's wrong or unclear? Submit a pull request.

Make a contribution

O, learn how to contribute.

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. For more information, see "Workflow syntax for 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 GITHUB_ENV environment file to set an environment variable that the following steps in a workflow can use. The environment file 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."

Default environment variables

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.

Environment variableDescription
CIAlways set to true.
HOMEThe path to the GitHub home directory used to store user data. For example, /github/home.
GITHUB_WORKFLOWThe name of the workflow.
GITHUB_RUN_IDUn número único para cada ejecución dentro de un repositorio. Este número no cambia si vuelves a ejecutar el flujo de trabajo.
GITHUB_RUN_NUMBERUn número único para cada ejecución de un flujo de trabajo particular en un repositorio. Este número comienza en 1 para los flujos de trabajo que se ejecutan primero, e incrementa con cada ejecución nueva. Este número no cambia si vuelves a ejecutar el flujo de trabajo.
GITHUB_ACTIONThe unique identifier (id) of the action.
GITHUB_ACTIONSAlways 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_ACTORThe name of the person or app that initiated the workflow. For example, octocat.
GITHUB_REPOSITORYThe owner and repository name. For example, octocat/Hello-World.
GITHUB_EVENT_NAMEThe name of the webhook event that triggered the workflow.
GITHUB_EVENT_PATHThe path of the file with the complete webhook event payload. For example, /github/workflow/event.json.
GITHUB_WORKSPACEThe GitHub workspace directory path. The workspace directory is a copy of your repository if your workflow uses the actions/checkout action. If you don't use the actions/checkout action, the directory will be empty. For example, /home/runner/work/my-repo-name/my-repo-name.
GITHUB_SHAThe commit SHA that triggered the workflow. For example, ffac537e6cbbf934b08745a378932722df287a53.
GITHUB_REFThe branch or tag ref that triggered the workflow. For example, refs/heads/feature-branch-1. If neither a branch or tag is available for the event type, the variable will not exist.
GITHUB_HEAD_REFOnly set for forked repositories. The branch of the head repository.
GITHUB_BASE_REFOnly set for forked repositories. The branch of the base repository.
GITHUB_SERVER_URLReturns the URL of the GitHub server. For example: https://github.com.
GITHUB_API_URLReturns the API URL. For example: https://api.github.com.
GITHUB_GRAPHQL_URLReturns the GraphQL API URL. For example: https://api.github.com/graphql.

Naming conventions for environment variables

Note: GitHub reserves the GITHUB_ environment variable prefix for internal use by GitHub. Setting an environment variable or secret with the GITHUB_ prefix will result in an error.

Any new environment variables you set that point to a location on the filesystem should have a _PATH suffix. The HOME and GITHUB_WORKSPACE default variables are exceptions to this convention because the words "home" and "workspace" already imply a location.

¿Te ayudó este documento?

Help us make these docs great!

All GitHub docs are open source. See something that's wrong or unclear? Submit a pull request.

Make a contribution

O, learn how to contribute.