Skip to main content

Delete workflow and all its runs

Why delete an entire workflow GitHub Actions ?

  • You have created experimental workflows in the .github/workflows folder of your repository and you want to delete them permanently.
  • You have accidentally leaked confidential information or credentials in the logs of a workflow and you want to erase them.
  • You want to rename your workflow and don't want to keep the old name in the list of available workflows.
warning

Note that this operation is irreversible and you will lose all logs and artifacts associated with the deleted workflow. If you want to keep a record of your old workflows, you can archive them in a separate branch or repository before deleting them.

How to delete all GitHub Actions workflow

Install the GitHub CLI

sudo apt install gh

Log in to your GitHub account

gh auth login

Then, follow the instructions.

Command to delete all workflows

caution

GH_USERNAME_OR_ORG is your GitHub username or organization name.

user="GH_USERNAME_OR_ORG" repo="REPO_NAME"; gh api repos/$user/$repo/actions/runs \
--paginate -q '.workflow_runs[] | "\(.id)"' | \
xargs -n1 -I % gh api --silent repos/$user/$repo/actions/runs/% -X DELETE

The command will take a long time to run if you have a lot of workflows.

info

May need to re-run the command to delete all workflows, because of the rate limit of the GitHub API.

tip
  • Remove the --silent flag to see the output of the command.
  • Add & to the end of the command to run it in the background.