Add support for workflow jobs and steps (#1951)

Co-authored-by: Enrico Minack <github@enrico.minack.dev>
This commit is contained in:
Jeppe Fihl-Pearson
2023-06-20 14:37:56 +08:00
committed by GitHub
co-authored by Enrico Minack
parent cb50dec5ba
commit 804c3107c8
11 changed files with 537 additions and 2 deletions
+23
View File
@@ -26,6 +26,7 @@ from collections import namedtuple
import github.Artifact
import github.GithubObject
import github.PullRequest
import github.WorkflowJob
class WorkflowRun(github.GithubObject.CompletableGithubObject):
@@ -302,6 +303,28 @@ class WorkflowRun(github.GithubObject.CompletableGithubObject):
status, _, _ = self._requester.requestJson("DELETE", self.url)
return status == 204
def jobs(self, _filter=github.GithubObject.NotSet):
"""
:calls "`GET /repos/{owner}/{repo}/actions/runs/{run_id}/jobs <https://docs.github.com/en/rest/reference/actions#list-jobs-for-a-workflow-run>`_
:param _filter: string `latest`, or `all`
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.WorkflowJob.WorkflowJob`
"""
assert _filter is github.GithubObject.NotSet or isinstance(
_filter, str
), _filter
url_parameters = dict()
if _filter is not github.GithubObject.NotSet:
url_parameters["filter"] = _filter
return github.PaginatedList.PaginatedList(
github.WorkflowJob.WorkflowJob,
self._requester,
self.jobs_url,
url_parameters,
list_item="jobs",
)
def _initAttributes(self):
self._id = github.GithubObject.NotSet
self._name = github.GithubObject.NotSet