From 5ffefdc214895bc9669cc3899b60586c5d6babda Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Thu, 25 Mar 2021 14:06:46 +0100 Subject: [PATCH 1/3] Deployments: use correct media-type for in_progress/queued, inactive --- lib/Github/Api/Deployment.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/Github/Api/Deployment.php b/lib/Github/Api/Deployment.php index 6fa8700a6da..d698b078cc9 100644 --- a/lib/Github/Api/Deployment.php +++ b/lib/Github/Api/Deployment.php @@ -87,6 +87,15 @@ public function updateStatus($username, $repository, $id, array $params) if (!isset($params['state'])) { throw new MissingArgumentException(['state']); } + + // adjust media-type per github docs + // https://docs.github.com/en/rest/reference/repos#create-a-deployment-status + if ($params['state'] === 'inactive') { + $this->acceptHeaderValue = 'application/vnd.github.ant-man-preview+json'; + } + if ($params['state'] === 'in_progress' || $params['state'] === 'queued') { + $this->acceptHeaderValue = 'application/vnd.github.flash-preview+json'; + } return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/deployments/'.$id.'/statuses', $params); } From bf3eb1f715254c6c05035f82a8c670c12f705a1c Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Thu, 25 Mar 2021 14:07:39 +0100 Subject: [PATCH 2/3] Update Deployment.php --- lib/Github/Api/Deployment.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/Github/Api/Deployment.php b/lib/Github/Api/Deployment.php index d698b078cc9..c3b100b2210 100644 --- a/lib/Github/Api/Deployment.php +++ b/lib/Github/Api/Deployment.php @@ -11,6 +11,8 @@ */ class Deployment extends AbstractApi { + use AcceptHeaderTrait; + /** * List deployments for a particular repository. * From ca128f6bf94cf955be2dfb34d6a75bfce8073a0d Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Thu, 25 Mar 2021 14:13:19 +0100 Subject: [PATCH 3/3] cs --- lib/Github/Api/Deployment.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Github/Api/Deployment.php b/lib/Github/Api/Deployment.php index c3b100b2210..454d59db0be 100644 --- a/lib/Github/Api/Deployment.php +++ b/lib/Github/Api/Deployment.php @@ -89,7 +89,7 @@ public function updateStatus($username, $repository, $id, array $params) if (!isset($params['state'])) { throw new MissingArgumentException(['state']); } - + // adjust media-type per github docs // https://docs.github.com/en/rest/reference/repos#create-a-deployment-status if ($params['state'] === 'inactive') { @@ -97,7 +97,7 @@ public function updateStatus($username, $repository, $id, array $params) } if ($params['state'] === 'in_progress' || $params['state'] === 'queued') { $this->acceptHeaderValue = 'application/vnd.github.flash-preview+json'; - } + } return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/deployments/'.$id.'/statuses', $params); }