Skip to content

Instantly share code, notes, and snippets.

@ka2n
Last active August 29, 2022 06:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ka2n/d462d3c1ef0a234b80289ac23ee5a39a to your computer and use it in GitHub Desktop.
Save ka2n/d462d3c1ef0a234b80289ac23ee5a39a to your computer and use it in GitHub Desktop.
Delete some environments from GitHub
owner=
repo=
gh api repos/{owner}/{repo}/environments\?per_page=100 |
jq '.environments[] | select(.name | (contains("production") or contains("preview")) | not) | .node_id' |
xargs -n1 -I% sh -c "
gh api graphql -F query='
mutation {
deleteEnvironment(input: { id: \"%\"}) {
clientMutationId
}
}
'
"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment