Created
February 16, 2026 10:05
-
-
Save arnaudrenaud/c6107864c2b8d61184a540b9168d3226 to your computer and use it in GitHub Desktop.
Remove GitHub Actions workflow from menu (delete all runs)
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 | |
| # Delete all the runs for a given workflow | |
| # This removes workflow from menu | |
| # Usage: ./delete-github-actions-workflow-runs.sh <repository> <workflow-name> | |
| set -oe pipefail | |
| REPOSITORY=$1 | |
| WORKFLOW_NAME=$2 | |
| # Validate arguments | |
| if [[ -z "$REPOSITORY" ]]; then | |
| echo "Repository is required" | |
| exit 1 | |
| fi | |
| if [[ -z "$WORKFLOW_NAME" ]]; then | |
| echo "Workflow name is required" | |
| exit 1 | |
| fi | |
| echo "Getting all completed runs for workflow $WORKFLOW_NAME in $REPOSITORY" | |
| RUNS=$( | |
| gh api \ | |
| -H "Accept: application/vnd.github+json" \ | |
| -H "X-GitHub-Api-Version: 2022-11-28" \ | |
| "/repos/$REPOSITORY/actions/workflows/$WORKFLOW_NAME/runs" \ | |
| --paginate \ | |
| --jq '.workflow_runs[] | select(.conclusion != "") | .id' | |
| ) | |
| echo "Found $(echo "$RUNS" | wc -l) completed runs for workflow $WORKFLOW_NAME" | |
| for RUN in $RUNS; do | |
| gh run delete --repo $REPOSITORY $RUN || echo "Failed to delete run $RUN" | |
| sleep 0.1 | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment