#!/usr/bin/env bash # Purpose: Cleans up old GitHub Actions workflow runs. Old runs are not automatically cleaned up when a workflow is removed, # so old, temporary, or dev/experimental workflows may leave useless noise. # # ORG, REPO, and WORKFLOW_ID must be set. WORKFLOW_ID can be obtained by inspecting 'gh api repos/$ORG/$REPO/actions/workflows' set -eux -o pipefail gh api "repos/$ORG/$REPO/actions/workflows/$WORKFLOW_ID/runs" --paginate -q '.workflow_runs[] | "\(.id)"' | \ xargs -n1 -I % gh api "repos/$ORG/$REPO/actions/workflows/$WORKFLOW_ID/runs/%" -X DELETE