Last active
October 12, 2024 22:06
-
-
Save gubatron/47552e1bfa345a142b2248be1925efb6 to your computer and use it in GitHub Desktop.
Batch delete 30 Github Workflow Run Logs using the github command line tool
This file contains 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
# | |
# 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