@@ -26,28 +26,57 @@ public function all(string $username, string $repository, array $parameters = []
2626 /**
2727 * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#get-a-workflow
2828 *
29- * @param string $username
30- * @param string $repository
31- * @param int $workflowId
29+ * @param string $username
30+ * @param string $repository
31+ * @param string| int $workflow
3232 *
3333 * @return array
3434 */
35- public function show (string $ username , string $ repository , int $ workflowId )
35+ public function show (string $ username , string $ repository , $ workflow )
3636 {
37- return $ this ->get ('/repos/ ' .rawurlencode ($ username ).'/ ' .rawurlencode ($ repository ).'/actions/workflows/ ' .$ workflowId );
37+ if (is_string ($ workflow )) {
38+ $ workflow = rawurlencode ($ workflow );
39+ }
40+
41+ return $ this ->get ('/repos/ ' .rawurlencode ($ username ).'/ ' .rawurlencode ($ repository ).'/actions/workflows/ ' .$ workflow );
3842 }
3943
4044 /**
4145 * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#get-workflow-usage
4246 *
43- * @param string $username
44- * @param string $repository
45- * @param int $workflowId
47+ * @param string $username
48+ * @param string $repository
49+ * @param string| int $workflow
4650 *
4751 * @return array|string
4852 */
49- public function usage (string $ username , string $ repository , int $ workflowId )
53+ public function usage (string $ username , string $ repository , $ workflow )
54+ {
55+ if (is_string ($ workflow )) {
56+ $ workflow = rawurlencode ($ workflow );
57+ }
58+
59+ return $ this ->get ('/repos/ ' .rawurlencode ($ username ).'/ ' .rawurlencode ($ repository ).'/actions/workflows/ ' .$ workflow .'/timing ' );
60+ }
61+
62+ /**
63+ * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#create-a-workflow-dispatch-event
64+ *
65+ * @param string $username
66+ * @param string $repository
67+ * @param string|int $workflow
68+ * @param string $ref
69+ * @param array $inputs
70+ *
71+ * @return array|string empty
72+ */
73+ public function dispatches (string $ username , string $ repository , $ workflow , string $ ref , array $ inputs = null )
5074 {
51- return $ this ->get ('/repos/ ' .rawurlencode ($ username ).'/ ' .rawurlencode ($ repository ).'/actions/workflows/ ' .$ workflowId .'/timing ' );
75+ if (is_string ($ workflow )) {
76+ $ workflow = rawurlencode ($ workflow );
77+ }
78+ $ parameters = array_filter (['ref ' => $ ref , 'inputs ' => $ inputs ]);
79+
80+ return $ this ->post ('/repos/ ' .rawurlencode ($ username ).'/ ' .rawurlencode ($ repository ).'/actions/workflows/ ' .$ workflow .'/dispatches ' , $ parameters );
5281 }
5382}
0 commit comments