Specify a deployment environment in your workflow.
You need to create an environment before you can use it in a workflow. See Managing environments for deployment.
Open the workflow file you want to edit.
Use the following syntax to add a jobs.<job_id>.environment key to your workflow:
jobs:
JOB-ID:
environment: ENVIRONMENT-NAME
The 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:
jobs:
JOB-ID:
environment:
name: ENVIRONMENT-NAME
url: URL
The specified URL will appear:
Optionally, prevent a deployment object from being created by adding the deployment property. When set to false, the job still has access to environment secrets and variables, but no GitHub deployment is created:
jobs:
JOB-ID:
environment:
name: ENVIRONMENT-NAME
deployment: false
This is useful for CI or testing jobs that need environment secrets but aren't actually deploying anything. For more information, see Deploying with GitHub Actions.