Skip to main content

Using environments for jobs

Specify an environment for a job.

Note: GitHub-hosted runners are not currently supported on GitHub Enterprise Server. You can see more information about planned future support on the GitHub public roadmap.


Use jobs.<job_id>.environment to define the environment that the job references. All environment protection rules must pass before a job referencing the environment is sent to a runner. For more information, see "Using environments for deployment."

You can provide the environment as only the environment name, or as an environment object with the name and url. The URL maps to environment_url in the deployments API. For more information about the deployments API, see "Repositories."

Example: Using a single environment name

environment: staging_environment

Example: Using environment name and URL

  name: production_environment

The URL can be an expression and can use any context except for the secrets context. For more information about expressions, see "Expressions."

Example: Using output as URL

  name: production_environment
  url: ${{ steps.step_id.outputs.url_output }}