Last active
March 1, 2024 12:39
-
-
Save mertant/c44625eeaeebacc902c390be0b42705b to your computer and use it in GitHub Desktop.
GitHub CLI cheat sheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Install (MacOS); Check version is >= 2.43 as the --json option was added in https://github.com/cli/cli/pull/8474 | |
brew install gh | |
gh --version | |
## Run in repo root... | |
# Browse drafts | |
gh release list --limit 25 --json tagName,createdAt,isDraft | |
# List drafts older than 1 week (tags only, oldest first) | |
gh release list --limit 25 --json tagName,createdAt,isDraft --jq 'reverse | .[] | select(.isDraft and ((.createdAt | fromdateiso8601) < now - (7*24*60*60))) | .tagName' | |
# Delete old drafts: pipe the tags to `gh release delete`, one-by-one (asks confirmation for each) | |
gh release list --limit 25 --json tagName,createdAt,isDraft --jq 'reverse | .[] | select(.isDraft and ((.createdAt | fromdateiso8601) < now - (7*24*60*60))) | .tagName' | xargs -p -n 1 gh release delete |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment