gh-environment
Manage GitHub repository environments
TLDR
Display help about environment variables that can be used with gh
SYNOPSIS
gh env list [flags…]
PARAMETERS
--help
Show help for command
--json
Output JSON. Use --json fields to select fields like name, deployment_branches, prevent_self
--jq <text>
Filter JSON output with JMESPath expression
--limit <int>
Max environments to list (default 100)
--repo <[HOST/]OWNER/REPO>
Target specific repository
DESCRIPTION
The gh env command from the GitHub CLI tool lists environments configured for a GitHub repository.
Environments are a GitHub feature used with GitHub Actions to define deployment targets. They support protection rules like required reviewers, deployment branch restrictions, wait timers, and prevention of self-deployment.
By default, gh env list targets the repository in the current directory (detected via git remote). It displays a table with environment names and key settings. Use --json for machine-readable output or --limit to cap results.
This command requires GitHub CLI authentication via gh auth login. It reads repository data via the GitHub API, respecting your permissions. Ideal for CI/CD scripting, auditing deployments, or checking protection rules before Actions workflows.
CAVEATS
Read-only: lists environments but cannot create, update, or delete. Requires gh auth login and repo read access. Paginated results limited by --limit.
EXAMPLE USAGE
gh env list
Lists environments for current repo.
gh env list --repo cli/cli --limit 10 --json name,deployment_branches
JSON output for specific repo.
JSON FIELDS
Key fields: name, deployment_branches (array), prevent_self (bool), wait_timer (int), reviewers (array of teams/users), review_count (int).
Use gh env list --json | gh jq . for details.
HISTORY
Introduced in GitHub CLI v2.5.0 (early 2022) as part of Actions management expansion.


