Deletes all but most recent Github codespaces, for a given repo.
Prerequisite: Install Github CLI, then auth as below:
gh auth refresh -h github.com -s codespace
Deletes all but most recent Github codespaces, for a given repo.
Prerequisite: Install Github CLI, then auth as below:
gh auth refresh -h github.com -s codespace
| #!/bin/bash | |
| repo=$1 | |
| [[ $# -eq 0 ]] && echo "Error: Specify a repo (can be a filter pattern, not necessarily full 'user/repo')" >&2 && exit 1 | |
| old_codespaces=$(gh codespace list --json name,repository -q ".[] | select(.repository? | contains(\"$repo\")) | .name" | head -n -1) | |
| for codespace in $(echo $old_codespaces); do | |
| echo "Deleting $codespace" | |
| gh codespace delete -c $codespace | |
| done | |
| echo DONE |