Prerequisites
You need to create an environment before you can use it in a workflow. See Managing environments for deployment.
Using an environment in a workflow
- 
Open the workflow file you want to edit.
 - 
Use the following syntax to add a
jobs.<job_id>.environmentkey to your workflow:YAML jobs: JOB-ID: environment: ENVIRONMENT-NAMEjobs: JOB-ID: environment: ENVIRONMENT-NAMEThe chosen job will now be subject to any rules configured for the specified environment.
 - 
Optionally, specify a deployment URL for the environment using the following syntax:
YAML jobs: JOB-ID: environment: name: ENVIRONMENT-NAME url: URLjobs: JOB-ID: environment: name: ENVIRONMENT-NAME url: URLThe specified URL will appear:
- On the deployments page for the repository
 - In the visualization graph for the workflow run
 - (If a pull request triggers the workflow) As a "View deployment" button in the pull request timeline