Skip to content

Instantly share code, notes, and snippets.

@zulhfreelancer
Last active April 13, 2023 06:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save zulhfreelancer/cb5c5879280fd7b3ab3ff356f75c74bd to your computer and use it in GitHub Desktop.
Save zulhfreelancer/cb5c5879280fd7b3ab3ff356f75c74bd to your computer and use it in GitHub Desktop.
How to bulk delete or leave all Heroku apps using bash script, Heroku CLI and jq?
# List all apps
heroku apps
# Delete all apps created by yourself
for app in $(heroku apps --json | jq -r '.[] | select(.owner.email == "<insert-heroku-email-here>") | .name'); do echo $app | heroku apps:destroy $app; done
# Leave all apps created by others where you were a collaborator
for app in $(heroku apps --json | jq -r '.[] | select(.owner.email != "<insert-heroku-email-here>") | .name'); do heroku apps:leave -a $app; done
# List all apps again
heroku apps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment