From 0c2815f2719b8dbf9d36b8a45c52478cae16dede Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Thu, 25 Mar 2021 19:03:17 +0100 Subject: [PATCH] bug #979 Deployments: use proper media-type for in_progress/queued, inactive state (staabm) This PR was squashed before being merged into the 3.1.x-dev branch. Discussion ---------- closes /~https://github.com/KnpLabs/php-github-api/issues/978 Commits ------- 5ffefdc214895bc9669cc3899b60586c5d6babda Deployments: use correct media-type for in_progress/queued, inactive bf3eb1f715254c6c05035f82a8c670c12f705a1c Update Deployment.php ca128f6bf94cf955be2dfb34d6a75bfce8073a0d cs --- lib/Github/Api/Deployment.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/Github/Api/Deployment.php b/lib/Github/Api/Deployment.php index 6fa8700a6da..454d59db0be 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. * @@ -88,6 +90,15 @@ public function updateStatus($username, $repository, $id, array $params) 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); }