Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save guotingchao/4b1f8ebe59d0d0fb0ddea7643a1b40bd to your computer and use it in GitHub Desktop.
Save guotingchao/4b1f8ebe59d0d0fb0ddea7643a1b40bd to your computer and use it in GitHub Desktop.
Batch delete 30 Github Workflow Run Logs using the github command line tool
#
# This script uses the github command line tool
# to delete the last 30 logs from your repository's workflow runs
#
# Requirements
#
# gh - github command line (brew install gh)
# you will need a GH_TOKEN, create it here: https://github.com/settings/tokens
#
# once you've created the personal access token with permission to manage your workflows
# you gotta tell gh which repository it's working with using
# $ gh repo set-default
# you will be presented an interactive list to pick the repo you want to delete workflow logs from
# jq - json command line processor (brew
repo=yourrepo
user=yourgithubusername
WORKFLOW_RUN_IDS=$(gh api /repos/${user}/${repo}/actions/runs | jq -r ".workflow_runs[] | [.id] | @tsv")
for id in ${WORKFLOW_RUN_IDS}
do
echo "Workflow ID: ${id}"
gh api -X DELETE "/repos/${user}/${repo}/actions/runs/${id}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment