Last active
December 15, 2021 21:31
-
-
Save abelaska/8d068e86a83f5fc099fe042f59964e46 to your computer and use it in GitHub Desktop.
Delete all the old workflows that aren't on the `main` branch
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
user=sli-do repo=slido-global-api; gh api repos/$user/$repo/actions/runs \ | |
--paginate -q '.workflow_runs[] | select(.head_branch != "main") | "\(.id)"' | \ | |
xargs -n1 -I % gh api --silent repos/$user/$repo/actions/runs/% -X DELETE | |
https://stackoverflow.com/a/64473987 | |
Prerequisites: | |
You will find the latest gh version here. | |
Notes: | |
You may have to gh auth login if this is your first time using it | |
You may further change the command to gh api --silent if you prefer not to see the verbose output. | |
For the final xargs part of the command chain - the original used -J instead of -I, which is not supported by GNU xargs. -J results in a single command, and -I will execute the command for each records, so it's a bit slower. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment