Skip to content

Instantly share code, notes, and snippets.

@thiskevinwang
Created April 1, 2023 13:12
Show Gist options
  • Save thiskevinwang/ab2fae60383dabe90c758f35ca08389c to your computer and use it in GitHub Desktop.
Save thiskevinwang/ab2fae60383dabe90c758f35ca08389c to your computer and use it in GitHub Desktop.
Delete GitHub environments
#!bin/sh
# This script fetches GitHub environments and delets them
# - requires the `gh` CLI
# - requires `jq`
envs=$(gh api repos/{owner}/{repo}/environments --paginate | jq -r ".environments[].name")
for env in $envs
do
echo "Deleting $env"
gh api repos/{owner}/{repo}/environments/$env -X DELETE
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment