Created
December 18, 2024 01:17
-
-
Save clarkritchie/071a3cbced4f5286d751bce0099fed61 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env bash | |
OWNER=clarkritchie | |
REPO=${1:-database} | |
WORKFLOW_ID=${2} | |
if [ -z "$WORKFLOW_ID" ]; then | |
echo "Must specify a workflow name" | |
exit 1 | |
fi | |
# gh config set pager cat | |
# GH_PAGER=cat | |
cat <<EOF | |
You are about to delete the workflow run history for: | |
- Owner: $OWNER | |
- Repository: $REPO | |
- Workflow ID: $WORKFLOW_ID | |
EOF | |
read -p "Do you want to proceed? (yes/no): " confirmation | |
if [[ "$confirmation" == "yes" ]]; then | |
gh api repos/$OWNER/$REPO/actions/workflows/$WORKFLOW_ID/runs --paginate -q '.workflow_runs[] | select(.head_branch != "master") | "\(.id)"' | \ | |
xargs -n1 -I % gh api repos/$OWNER/$REPO/actions/runs/% -X DELETE | |
else | |
echo "Operation cancelled." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment