Home / Alt manpages / gh-run-delete(1)

  • gh-run-delete(1)
  • User command
  • linux

Delete the Right GitHub Actions Run with gh run delete

You will finish with a repeatable way to identify one GitHub Actions workflow run and delete it with gh run delete. The command used here is from GitHub CLI 2.87.3, installed as gh on the machine used for this guide.

Allow about ten minutes, plus time to check the run carefully. You need GitHub CLI, an authenticated account with access to the repository, and the repository owner and name. This guide does not need sudo. Deleting a run changes remote GitHub data and is not reversible through gh, so keep any logs or other evidence you may need before the deletion.

1. Check the installed command

Confirm which executable and version will receive the destructive command. This is a read-only check:

$ command -v gh
/home/linuxbrew/.linuxbrew/bin/gh
$ gh --version
gh version 2.87.3 (2026-02-23)

Now inspect the command's local help:

$ gh run delete --help
Delete a workflow run

USAGE
  gh run delete [<run-id>] [flags]

INHERITED FLAGS
      --help                     Show help for command
  -R, --repo [HOST/]OWNER/REPO   Select another repository using the [HOST/]OWNER/REPO format

There is no --yes or dry-run flag in this installed command. With no run ID, it interactively selects a run. With a run ID, it deletes that specific run. Treat the absence of a confirmation-suppression option as a reason to do the identity checks below, not as permission to automate blindly.

2. Set the repository explicitly

Work from any directory by storing the repository in a shell variable. Replace the example with the repository you have checked:

$ REPO='OWNER/REPOSITORY'
$ printf 'target repository: %s\n' "$REPO"
target repository: OWNER/REPOSITORY

Use the -R or --repo option on every command in this guide. It accepts [HOST/]OWNER/REPO, so a GitHub Enterprise repository can include its host:

$ gh run list --repo "$REPO" --limit 20

The list is for discovery only. Record the numeric run ID, workflow name, branch, commit and status of the run you intend to remove. Do not choose a row merely because its display title looks familiar. Several runs can share a commit or pull request title.

Checkpoint

You should have one repository value and one candidate numeric run ID written down. If the repository is wrong, stop here and correct REPO.

3. Inspect the candidate before deleting it

Use the run ID from the list to inspect the run. Replace 123456789 with your candidate:

$ RUN_ID='123456789'
$ gh run view "$RUN_ID" --repo "$REPO"

Compare the displayed workflow, branch, commit and status with the reason you are cleaning up. If the run contains logs that may be useful for an incident, save them before changing remote state:

$ gh run view "$RUN_ID" --repo "$REPO" --log > "run-$RUN_ID.log"
$ test -s "run-$RUN_ID.log" && echo "saved run log"
saved run log

The log command writes locally in the current directory. Check the file before deleting the remote run, and store it where your team keeps operational evidence. If the run is still active, consider whether cancellation or investigation is the right action instead. Deletion is a cleanup action, not a substitute for understanding a failing workflow.

4. Delete by explicit run ID

When the identity checks match, run the destructive command:

$ gh run delete "$RUN_ID" --repo "$REPO"

A successful command may produce no output. Check the exit status immediately if you are scripting around it:

$ status=$?
$ printf 'delete exit status: %s\n' "$status"
delete exit status: 0

Exit status 0 confirms that the CLI completed the delete request. It does not provide a recovery point. The command has no undo operation, and rerunning a workflow would create a new run rather than restore the deleted one.

Warning

Do not substitute a guessed ID, a workflow number or a pull request number. gh run delete expects the workflow run ID. Use the numeric ID returned by the run list or shown by the run view command.

5. Verify the repository no longer lists the run

Ask the same repository for the run ID after deletion:

$ gh run view "$RUN_ID" --repo "$REPO"

For a deleted run, this lookup should fail rather than display the old run. The exact error text can vary with the CLI and server response. Check the status without hiding it:

$ gh run view "$RUN_ID" --repo "$REPO" >/tmp/gh-run-view.out 2>/tmp/gh-run-view.err
$ status=$?
$ printf 'lookup exit status: %s\n' "$status"
$ sed -n '1,3p' /tmp/gh-run-view.err
lookup exit status: 1

A non-zero lookup is expected only after you have confirmed that the command used the same repository and run ID. If the view command still shows the run, do not repeat deletion: check the target repository, authentication context and server response first.

6. Use interactive selection only when you can review it

With no run ID, the command offers an interactive selection:

$ gh run delete --repo "$REPO"

This is useful at a terminal when you want to choose from the repository's runs. It is a poor fit for cron jobs, scripts or pasted commands because the selected row is easy to misread and there is no run ID in the command line for a reviewer to audit. For repeatable work, identify the run with gh run list, inspect it with gh run view, then pass the explicit ID.

If the command reports that you are not authorised, stop rather than trying sudo. GitHub permissions and the selected account control access to the repository; local root privileges do not grant remote GitHub access. Check the account and repository with your normal gh auth workflow, then rerun the read-only list or view command.

Done means

  • You confirmed the installed gh version and command syntax.
  • You selected the repository explicitly with --repo.
  • You matched the run ID, workflow, branch and commit before deleting anything.
  • You saved logs locally if they might be needed later.
  • You deleted one explicit run ID and checked the command status.
  • A follow-up lookup no longer finds the run, and you understand that the deletion cannot be undone by gh.