curity-guides/using-githubs-security-features-to-secure-your-use-of-github-actions)
    * [ Automatic token authentication  ](/en/actions/security-guides/automatic-token-authentication)

  * Creating actions 

    * [ About custom actions  ](/en/actions/creating-actions/about-custom-actions)
    * [ Create a Docker container action  ](/en/actions/creating-actions/creating-a-docker-container-action)
    * [ Create a JavaScript action  ](/en/actions/creating-actions/creating-a-javascript-action)
    * [ Create a composite action  ](/en/actions/creating-actions/creating-a-composite-action)
    * [ Metadata syntax  ](/en/actions/creating-actions/metadata-syntax-for-github-actions)
    * [ Dockerfile support  ](/en/actions/creating-actions/dockerfile-support-for-github-actions)
    * [ Set exit codes  ](/en/actions/creating-actions/setting-exit-codes-for-actions)
    * [ Publish in GitHub Marketplace  ](/en/actions/creating-actions/publishing-actions-in-github-marketplace)
    * [ Share from your private repository  ](/en/actions/creating-actions/sharing-actions-and-workflows-from-your-private-repository)
    * [ Share with your organization  ](/en/actions/creating-actions/sharing-actions-and-workflows-with-your-organization)
    * [ Release and maintain actions  ](/en/actions/creating-actions/releasing-and-maintaining-actions)
    * [ CLI setup action  ](/en/actions/creating-actions/developing-a-third-party-cli-action)

  * [ Guides for GitHub Actions  ](/en/actions/guides)

  * [ GitHub Actions ](/en/actions "GitHub Actions") / 
  * [ Using jobs ](/en/actions/using-jobs "Using jobs") / 
  * [ Environments ](/en/actions/using-jobs/using-environments-for-jobs "Environments")

#  Using environments for jobs

Specify an environment for a job.

##  Overview

Use ` jobs.<job_id>.environment ` to define the environment that the job
references. All deployment protection rules must pass before a job referencing
the environment is sent to a runner. For more information, see " [ Using
environments for deployment ](/en/actions/deployment/targeting-different-
environments/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 " [ REST API endpoints for repositories
](/en/rest/repos#deployments) ."

###  Example: Using a single environment name

    
    
    environment: staging_environment
    

###  Example: Using environment name and URL

    
    
    environment:
      name: production_environment
      url: https://github.com
    

The value of ` url ` can be an expression. Allowed expression contexts: [ `
github ` ](/en/actions/learn-github-actions/contexts#github-context) , [ `
inputs ` ](/en/actions/learn-github-actions/contexts#inputs-context) , [ `
vars ` ](/en/actions/learn-github-actions/contexts#vars-context) , [ ` needs `
](/en/actions/learn-github-actions/contexts#needs-context) , [ ` strategy `
](/en/actions/learn-github-actions/contexts#strategy-context) , [ ` matrix `
](/en/actions/learn-github-actions/contexts#matrix-context) , [ ` job `
](/en/actions/learn-github-actions/contexts#job-context) , [ ` runner `
](/en/actions/learn-github-actions/contexts#runner-context) , and [ ` env `
](/en/actions/learn-github-actions/contexts#env-context) . For more
information about expressions, see " [ Expressions ](/en/actions/learn-github-
actions/expressions) ."

###  Example: Using output as URL

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

The value of ` name ` can be an expression. Allowed expression contexts: [ `
github ` ](/en/actions/learn-github-actions/contexts#github-context) , [ `
inputs ` ](/en/actions/learn-github-actions/contexts#inputs-context) , [ `
vars ` ](/en/actions/learn-github-actions/contexts#vars-context) , [ ` needs `
]