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