Add support for workflow dispatch event (#1625)

* Add support for workflow dispatch event

Fixes: #1624
This commit is contained in:
Mahesh Raju
2020-07-30 16:43:05 +10:00
committed by GitHub
parent 136a3e8008
commit 16850ef1ed
7 changed files with 264 additions and 1 deletions
+27
View File
@@ -106,6 +106,33 @@ class Workflow(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._badge_url)
return self._badge_url.value
def create_dispatch(self, ref, inputs=github.GithubObject.NotSet):
"""
:calls: `POST /repos/:owner/:repo/actions/workflows/:workflow_id/dispatches`_
:param ref: :class:`github.Branch.Branch` or :class:`github.Tag.Tag` or :class:`github.Commit.Commit` or string
:param inputs: dict
:rtype: bool
"""
assert (
isinstance(ref, github.Branch.Branch)
or isinstance(ref, github.Tag.Tag)
or isinstance(ref, github.Commit.Commit)
or isinstance(ref, str)
), ref
assert inputs is github.GithubObject.NotSet or isinstance(inputs, dict), inputs
if isinstance(ref, github.Branch.Branch):
ref = ref.name
elif isinstance(ref, github.Commit.Commit):
ref = ref.sha
elif isinstance(ref, github.Tag.Tag):
ref = ref.name
if inputs is github.GithubObject.NotSet:
inputs = {}
status, _, _ = self._requester.requestJson(
"POST", self.url + "/dispatches", input={"ref": ref, "inputs": inputs}
)
return status == 204
def get_runs(
self,
actor=github.GithubObject.NotSet,
+8 -1
View File
@@ -2,21 +2,28 @@ from datetime import datetime
from typing import Any, Dict, Union
from github.Branch import Branch
from github.Commit import Commit
from github.GithubObject import CompletableGithubObject, _NotSetType
from github.NamedUser import NamedUser
from github.PaginatedList import PaginatedList
from github.Tag import Tag
from github.WorkflowRun import WorkflowRun
class Workflow(CompletableGithubObject):
def __repr__(self) -> str: ...
def _initAttributes(self) -> None: ...
def _useAttributes(self, attributes: Dict[str, Any]) -> None: ...
def create_dispatch(
self,
ref: Union[str, Branch, Commit, Tag],
inputs: Union[Dict[str, Union[str, int, float]], _NotSetType],
) -> bool: ...
def get_runs(
self,
actor: Union[str, NamedUser, _NotSetType],
branch: Union[str, Branch, _NotSetType],
event: Union[str, _NotSetType],
status: Union[str, _NotSetType]
status: Union[str, _NotSetType],
) -> PaginatedList[WorkflowRun]: ...
@property
def id(self) -> int: ...