Skip to content

Instantly share code, notes, and snippets.

@ronek22
Created July 28, 2022 06:07
Show Gist options
  • Select an option

  • Save ronek22/29940b4db1821509ec730e46b60b97e5 to your computer and use it in GitHub Desktop.

Select an option

Save ronek22/29940b4db1821509ec730e46b60b97e5 to your computer and use it in GitHub Desktop.
Delete workflow runs

Requirements

  • GitHub CLI
#!/bin/bash
ORG="gigb-official"
REPO="django-gigb"
WORKFLOW="lint.yml"
gh config set pager cat
WORKFLOW_RUNS=$(gh api -H "Accept: application/vnd.github.v3+json" "/repos/$ORG/$REPO/actions/workflows/$WORKFLOW/runs?per_page=100" | jq '.workflow_runs[] | .id')
WORKFLOW_RUNS=($WORKFLOW_RUNS)
for s in "${WORKFLOW_RUNS[@]}"; do
gh api --method DELETE -H "Accept: application/vnd.github.v3+json" /repos/$ORG/$REPO/actions/runs/$s
done
gh config set pager less
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment