environments section configures deployment environments for GitHub Actions workflows. Environments provide deployment protection rules, reviewers, branch policies, and environment-specific variables.
Basic Configuration
The name of the environment. This will be referenced in workflows with
environment: <name>. Names are automatically converted to lowercase.Wait Timer
The amount of time to delay a job after the job is initially triggered. The time (in minutes) must be an integer between 0 and 43,200 (30 days).
Reviewers
Whether a user who created the job is prevented from approving their own job.
The people or teams that may review jobs that reference the environment. You can list up to six users or teams as reviewers. Only one of the required reviewers needs to approve the job for it to proceed.Important: Reviewers must be given explicit access to the repository as either a team or collaborator before they can be added as environment reviewers.
The type of reviewer. Can be:
User- An individual userTeam- A team
The ID of the user or team who can review the deployment.To get IDs:
- Team:
gh api /orgs/<org>/teams/<team-slug> | jq .id - User:
gh api /users/<username> | jq .id
Deployment Branch Policy
The type of deployment branch policy for this environment. Set to
null to allow all branches to deploy.Whether only branches with branch protection rules can deploy to this environment.
- If
protected_branchesistrue,custom_branch_policiesmust befalse - If
protected_branchesisfalse,custom_branch_policiesmust be an array
Whether only branches that match the specified name patterns can deploy to this environment.
- If
custom_branch_policiesisfalse,protected_branchesmust betrue - If
custom_branch_policiesis an array,protected_branchesmust befalse
- A string (branch name pattern) - automatically treated as
type: branch - An object with
namesarray andtypefield
Array of branch or tag name patterns.
The type of ref. Can be:
branch- Branch patternstag- Tag patterns
Allow All Branches
Protected Branches Only
Custom Branch Patterns
Simplified String Format
Environment Variables
Deployment Protection Rules
Complete Examples
Development Environment
Staging Environment
Production Environment
Multiple Environments
Important Notes
Reviewer Access
Reviewers must be given explicit access to the repository before they can be added as environment reviewers. Add them to theteams or collaborators section:
Branch Policy Validation
- You cannot set both
protected_branches: trueand providecustom_branch_policies - You must specify either
protected_branches: trueor providecustom_branch_policies - Setting
deployment_branch_policy: nullallows all branches to deploy
Variable Names
- Environment variable names are converted to lowercase by Safe Settings
- In your workflow, reference them as configured:
${{ vars.API_URL }}