Repository: PyGithub/PyGithub

Issue:
Add an option to delete workflow runs
This worked for me:

```python
# 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)  `



Discussion:

Resolving patch:
diff --git a/github/WorkflowRun.py b/github/WorkflowRun.py
--- a/github/WorkflowRun.py
+++ b/github/WorkflowRun.py
@@ -243,6 +243,14 @@ def timing(self):
         timingdata = namedtuple("TimingData", data.keys())
         return timingdata._make(data.values())
 
+    def delete(self):
+        """
+        :calls: `DELETE /repos/{owner}/{repo}/actions/runs/{run_id} <https://docs.github.com/en/rest/reference/actions#workflow-runs>`_
+        :rtype: bool
+        """
+        status, _, _ = self._requester.requestJson("DELETE", self.url)
+        return status == 204
+
     def _initAttributes(self):
         self._id = github.GithubObject.NotSet
         self._head_branch = github.GithubObject.NotSet


Test patch:
diff --git a/tests/ReplayData/WorkflowRun.test_delete.txt b/tests/ReplayData/WorkflowRun.test_delete.txt
new file mode 100644
--- /dev/null
+++ b/tests/ReplayData/WorkflowRun.test_delete.txt
@@ -0,0 +1,22 @@
+https
+GET
+api.github.com
+None
+/repos/PyGithub/PyGithub/actions/runs/1327550476
+{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
+None
+200
+[('Server', 'GitHub.com'), ('Date', 'Fri, 15 Oct 2021 04:26:27 GMT'), ('Content-Type', 'application/json; charset=utf-8'), ('Transfer-Encoding', 'chunked'), ('Cache-Control', 'private, max-age=60, s-maxage=60'), ('Vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding, Accept, X-Requested-With'), ('ETag', 'W/"9b4f8e8ab5123615826192c4e38f4d4062e898032cfecfa59e65d37afc169db4"'), ('X-OAuth-Scopes', 'admin:enterprise, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, repo, user, workflow, write:discussion, write:packages'), ('X-Accepted-OAuth-Scopes', ''), ('X-GitHub-Media-Type', 'github.v3; format=json'), ('X-RateLimit-Limit', '5000'), ('X-RateLimit-Remaining', '4994'), ('X-RateLimit-Reset', '1634274619'), ('X-RateLimit-Used', '6'), ('X-RateLimit-Resource', 'core'), ('Access-Control-Expose-Headers', 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset'), ('Access-Control-Allow-Origin', '*'), ('Strict-Transport-Security', 'max-age=31536000; includeSubdomains; preload'), ('X-Frame-Options', 'deny'), ('X-Content-Type-Options', 'nosniff'), ('X-XSS-Protection', '0'), ('Referrer-Policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('Content-Security-Policy', "default-src 'none'"), ('Content-Encoding', 'gzip'), ('X-GitHub-Request-Id', 'E6E2:25CB:1AFF04:1DC5D9:616902F2')]
+{"id":1327550476,"name":"CI","node_id":"WFR_kwLOADYVqs5PINAM","head_branch":"python-310","head_sha":"952d71013bba0ca8027ff6aa4d707b966a2625f9","run_number":540,"event":"pull_request","status":"completed","conclusion":"failure","workflow_id":1903133,"check_suite_id":4014419209,"check_suite_node_id":"CS_kwDOADYVqs7vRy0J","url":"https://api.github.com/repos/PyGithub/PyGithub/actions/runs/1327550476","html_url":"https://github.com/PyGithub/PyGithub/actions/runs/1327550476","pull_requests":[],"created_at":"2021-10-11T04:50:48Z","updated_at":"2021-10-11T04:51:10Z","run_attempt":1,"run_started_at":"2021-10-11T04:50:48Z","jobs_url":"https://api.github.com/repos/PyGithub/PyGithub/actions/runs/1327550476/jobs","logs_url":"https://api.github.com/repos/PyGithub/PyGithub/actions/runs/1327550476/logs","check_suite_url":"https://api.github.com/repos/PyGithub/PyGithub/check-suites/4014419209","artifacts_url":"https://api.github.com/repos/PyGithub/PyGithub/actions/runs/1327550476/artifacts","cancel_url":"https://api.github.com/repos/PyGithub/PyGithub/actions/runs/1327550476/cancel","rerun_url":"https://api.github.com/repos/PyGithub/PyGithub/actions/runs/1327550476/rerun","previous_attempt_url":null,"workflow_url":"https://api.github.com/repos/PyGithub/PyGithub/actions/workflows/1903133","head_commit":{"id":"952d71013bba0ca8027ff6aa4d707b966a2625f9","tree_id":"4f3ccf0128dbc73c849519d50fa63e702d2acdbd","message":"Add support for Python 3.10\n\nNow that Python 3.10 has been released, we should test it in CI.","timestamp":"2021-10-11T04:50:06Z","author":{"name":"Steve Kowalik","email":"steven@wedontsleep.org"},"committer":{"name":"Steve Kowalik","email":"steven@wedontsleep.org"}},"repository":{"id":3544490,"node_id":"MDEwOlJlcG9zaXRvcnkzNTQ0NDkw","name":"PyGithub","full_name":"PyGithub/PyGithub","private":false,"owner":{"login":"PyGithub","id":11288996,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExMjg4OTk2","avatar_url":"https://avatars.githubusercontent.com/u/11288996?v=4","gravatar_id":"","url":"https://api.github.com/users/PyGithub","html_url":"https://github.com/PyGithub","followers_url":"https://api.github.com/users/PyGithub/followers","following_url":"https://api.github.com/users/PyGithub/following{/other_user}","gists_url":"https://api.github.com/users/PyGithub/gists{/gist_id}","starred_url":"https://api.github.com/users/PyGithub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PyGithub/subscriptions","organizations_url":"https://api.github.com/users/PyGithub/orgs","repos_url":"https://api.github.com/users/PyGithub/repos","events_url":"https://api.github.com/users/PyGithub/events{/privacy}","received_events_url":"https://api.github.com/users/PyGithub/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/PyGithub/PyGithub","description":"Typed interactions with the GitHub API v3","fork":false,"url":"https://api.github.com/repos/PyGithub/PyGithub","forks_url":"https://api.github.com/repos/PyGithub/PyGithub/forks","keys_url":"https://api.github.com/repos/PyGithub/PyGithub/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PyGithub/PyGithub/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PyGithub/PyGithub/teams","hooks_url":"https://api.github.com/repos/PyGithub/PyGithub/hooks","issue_events_url":"https://api.github.com/repos/PyGithub/PyGithub/issues/events{/number}","events_url":"https://api.github.com/repos/PyGithub/PyGithub/events","assignees_url":"https://api.github.com/repos/PyGithub/PyGithub/assignees{/user}","branches_url":"https://api.github.com/repos/PyGithub/PyGithub/branches{/branch}","tags_url":"https://api.github.com/repos/PyGithub/PyGithub/tags","blobs_url":"https://api.github.com/repos/PyGithub/PyGithub/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PyGithub/PyGithub/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PyGithub/PyGithub/git/refs{/sha}","trees_url":"https://api.github.com/repos/PyGithub/PyGithub/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PyGithub/PyGithub/statuses/{sha}","languages_url":"https://api.github.com/repos/PyGithub/PyGithub/languages","stargazers_url":"https://api.github.com/repos/PyGithub/PyGithub/stargazers","contributors_url":"https://api.github.com/repos/PyGithub/PyGithub/contributors","subscribers_url":"https://api.github.com/repos/PyGithub/PyGithub/subscribers","subscription_url":"https://api.github.com/repos/PyGithub/PyGithub/subscription","commits_url":"https://api.github.com/repos/PyGithub/PyGithub/commits{/sha}","git_commits_url":"https://api.github.com/repos/PyGithub/PyGithub/git/commits{/sha}","comments_url":"https://api.github.com/repos/PyGithub/PyGithub/comments{/number}","issue_comment_url":"https://api.github.com/repos/PyGithub/PyGithub/issues/comments{/number}","contents_url":"https://api.github.com/repos/PyGithub/PyGithub/contents/{+path}","compare_url":"https://api.github.com/repos/PyGithub/PyGithub/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PyGithub/PyGithub/merges","archive_url":"https://api.github.com/repos/PyGithub/PyGithub/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PyGithub/PyGithub/downloads","issues_url":"https://api.github.com/repos/PyGithub/PyGithub/issues{/number}","pulls_url":"https://api.github.com/repos/PyGithub/PyGithub/pulls{/number}","milestones_url":"https://api.github.com/repos/PyGithub/PyGithub/milestones{/number}","notifications_url":"https://api.github.com/repos/PyGithub/PyGithub/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PyGithub/PyGithub/labels{/name}","releases_url":"https://api.github.com/repos/PyGithub/PyGithub/releases{/id}","deployments_url":"https://api.github.com/repos/PyGithub/PyGithub/deployments"},"head_repository":{"id":129349732,"node_id":"MDEwOlJlcG9zaXRvcnkxMjkzNDk3MzI=","name":"PyGithub","full_name":"s-t-e-v-e-n-k/PyGithub","private":false,"owner":{"login":"s-t-e-v-e-n-k","id":15225059,"node_id":"MDQ6VXNlcjE1MjI1MDU5","avatar_url":"https://avatars.githubusercontent.com/u/15225059?v=4","gravatar_id":"","url":"https://api.github.com/users/s-t-e-v-e-n-k","html_url":"https://github.com/s-t-e-v-e-n-k","followers_url":"https://api.github.com/users/s-t-e-v-e-n-k/followers","following_url":"https://api.github.com/users/s-t-e-v-e-n-k/following{/other_user}","gists_url":"https://api.github.com/users/s-t-e-v-e-n-k/gists{/gist_id}","starred_url":"https://api.github.com/users/s-t-e-v-e-n-k/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/s-t-e-v-e-n-k/subscriptions","organizations_url":"https://api.github.com/users/s-t-e-v-e-n-k/orgs","repos_url":"https://api.github.com/users/s-t-e-v-e-n-k/repos","events_url":"https://api.github.com/users/s-t-e-v-e-n-k/events{/privacy}","received_events_url":"https://api.github.com/users/s-t-e-v-e-n-k/received_events","type":"User","site_admin":false},"html_url":"https://github.com/s-t-e-v-e-n-k/PyGithub","description":"Typed interactions with the GitHub API v3","fork":true,"url":"https://api.github.com/repos/s-t-e-v-e-n-k/PyGithub","forks_url":"https://api.github.com/repos/s-t-e-v-e-n-k/PyGithub/forks","keys_url":"https://api.github.com/repos/s-t-e-v-e-n-k/PyGithub/keys{/key_id}","collaborators_url":"https://api.github.com/repos/s-t-e-v-e-n-k/PyGithub/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/s-t-e-v-e-n-k/PyGithub/teams","hooks_url":"https://api.github.com/repos/s-t-e-v-e-n-k/PyGithub/hooks","issue_events_url":"https://api.github.com/repos/s-t-e-v-e-n-k/PyGithub/issues/events{/number}","events_url":"https://api.github.com/repos/s-t-e-v-e-n-k/PyGithub/events","assignees_url":"https://api.github.com/repos/s-t-e-v-e-n-k/PyGithub/assignees{/user}","branches_url":"https://api.github.com/repos/s-t-e-v-e-n-k/PyGithub/branches{/branch}","tags_url":"https://api.github.com/repos/s-t-e-v-e-n-k/PyGithub/tags","blobs_url":"https://api.github.com/repos/s-t-e-v-e-n-k/PyGithub/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/s-t-e-v-e-n-k/PyGithub/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/s-t-e-v-e-n-k/PyGithub/git/refs{/sha}","trees_url":"https://api.github.com/repos/s-t-e-v-e-n-k/PyGithub/git/trees{/sha}","statuses_url":"https://api.github.com/repos/s-t-e-v-e-n-k/PyGithub/statuses/{sha}","languages_url":"https://api.github.com/repos/s-t-e-v-e-n-k/PyGithub/languages","stargazers_url":"https://api.github.com/repos/s-t-e-v-e-n-k/PyGithub/stargazers","contributors_url":"https://api.github.com/repos/s-t-e-v-e-n-k/PyGithub/contributors","subscribers_url":"https://api.github.com/repos/s-t-e-v-e-n-k/PyGithub/subscribers","subscription_url":"https://api.github.com/repos/s-t-e-v-e-n-k/PyGithub/subscription","commits_url":"https://api.github.com/repos/s-t-e-v-e-n-k/PyGithub/commits{/sha}","git_commits_url":"https://api.github.com/repos/s-t-e-v-e-n-k/PyGithub/git/commits{/sha}","comments_url":"https://api.github.com/repos/s-t-e-v-e-n-k/PyGithub/comments{/number}","issue_comment_url":"https://api.github.com/repos/s-t-e-v-e-n-k/PyGithub/issues/comments{/number}","contents_url":"https://api.github.com/repos/s-t-e-v-e-n-k/PyGithub/contents/{+path}","compare_url":"https://api.github.com/repos/s-t-e-v-e-n-k/PyGithub/compare/{base}...{head}","merges_url":"https://api.github.com/repos/s-t-e-v-e-n-k/PyGithub/merges","archive_url":"https://api.github.com/repos/s-t-e-v-e-n-k/PyGithub/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/s-t-e-v-e-n-k/PyGithub/downloads","issues_url":"https://api.github.com/repos/s-t-e-v-e-n-k/PyGithub/issues{/number}","pulls_url":"https://api.github.com/repos/s-t-e-v-e-n-k/PyGithub/pulls{/number}","milestones_url":"https://api.github.com/repos/s-t-e-v-e-n-k/PyGithub/milestones{/number}","notifications_url":"https://api.github.com/repos/s-t-e-v-e-n-k/PyGithub/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/s-t-e-v-e-n-k/PyGithub/labels{/name}","releases_url":"https://api.github.com/repos/s-t-e-v-e-n-k/PyGithub/releases{/id}","deployments_url":"https://api.github.com/repos/s-t-e-v-e-n-k/PyGithub/deployments"}}
+
+https
+DELETE
+api.github.com
+None
+/repos/PyGithub/PyGithub/actions/runs/1327550476
+{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
+None
+204
+[('Server', 'GitHub.com'), ('Date', 'Fri, 15 Oct 2021 04:26:27 GMT'), ('X-OAuth-Scopes', 'admin:enterprise, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, repo, user, workflow, write:discussion, write:packages'), ('X-Accepted-OAuth-Scopes', ''), ('X-GitHub-Media-Type', 'github.v3; format=json'), ('X-RateLimit-Limit', '5000'), ('X-RateLimit-Remaining', '4993'), ('X-RateLimit-Reset', '1634274619'), ('X-RateLimit-Used', '7'), ('X-RateLimit-Resource', 'core'), ('Access-Control-Expose-Headers', 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset'), ('Access-Control-Allow-Origin', '*'), ('Strict-Transport-Security', 'max-age=31536000; includeSubdomains; preload'), ('X-Frame-Options', 'deny'), ('X-Content-Type-Options', 'nosniff'), ('X-XSS-Protection', '0'), ('Referrer-Policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('Content-Security-Policy', "default-src 'none'"), ('Vary', 'Accept-Encoding, Accept, X-Requested-With'), ('X-GitHub-Request-Id', 'E6E4:25CA:8C5D5:B7A0F:616902F3')]
+
+
diff --git a/tests/WorkflowRun.py b/tests/WorkflowRun.py
--- a/tests/WorkflowRun.py
+++ b/tests/WorkflowRun.py
@@ -105,3 +105,7 @@ def test_rerun_with_successful_run(self):
 
     def test_cancel(self):
         self.assertTrue(self.workflow_run.cancel())
+
+    def test_delete(self):
+        wr = self.repo.get_workflow_run(1327550476)
+        self.assertTrue(wr.delete())