Skip to content

Instantly share code, notes, and snippets.

@jasonrhaas
Created June 9, 2022 16:16
Show Gist options
  • Save jasonrhaas/36fd63d76ecb711dda76b4d410d011e6 to your computer and use it in GitHub Desktop.
Save jasonrhaas/36fd63d76ecb711dda76b4d410d011e6 to your computer and use it in GitHub Desktop.
from github import Github
import os
import sys
# First create a Github instance: using an access token
access_token = os.getenv('GITHUB_ACCESS_TOKEN')
g = Github(access_token)
# Select your repo
repo = g.get_repo('Stodge-Inc/postscript-api')
# Iterate through the workflows to find the id of the one you want to clean up
# for workflow in repo.get_workflows():
# print(workflow)
# sys.exit()
# Fill this in with the workflow you want to clean up
workflow_id = ''
workflow = repo.get_workflow(workflow_id)
print(workflow)
# Run through all the workflow runs and delete them one by one
# Note: The access token is rate limited so you may need to run this a few times
while True:
for run in workflow.get_runs():
print(run)
run.delete()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment