Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to delete workflow runs #2019

Closed
bauergeorg opened this issue Aug 6, 2021 · 1 comment · Fixed by #2078
Closed

Add an option to delete workflow runs #2019

bauergeorg opened this issue Aug 6, 2021 · 1 comment · Fixed by #2078

Comments

@bauergeorg
Copy link

This worked for me:

# get repo
repo = g.get_repo("repo name")

# list workflows
for workflow in repo.get_workflows():
    print("ID: '{}', Name: '{}', State: '{}'".format(workflow.id, workflow.name, workflow.state))

# get runs and delete workflow run: if workflow id match
for run in repo.get_workflow_runs():
    print("ID: '{}', Satus: '{}', Run Number: '{}', Workflow ID: '{}'".format(run.id, run.status, run.run_number, run.workflow_id))
    if run.workflow_id == xyz:
        print("delete ID: '{}'".format(run.workflow_id))
        repo._requester.requestJson("DELETE", run.url)  

Please add this into a function:
repo._requester.requestJson("DELETE", run.url)

s-t-e-v-e-n-k added a commit to s-t-e-v-e-n-k/PyGithub that referenced this issue Oct 15, 2021
One piece of missing functionality is the ability to delete Workflow
Runs, which the GitHub API supports. Add a delete() method to
WorkflowRun.

Fixes PyGithub#2019
s-t-e-v-e-n-k added a commit that referenced this issue Oct 15, 2021
One piece of missing functionality is the ability to delete Workflow
Runs, which the GitHub API supports. Add a delete() method to
WorkflowRun.

Fixes #2019
@bauergeorg
Copy link
Author

thanks @s-t-e-v-e-n-k

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant