/**
* Handles incoming requests to trigger deploy.
*
* @param Request $request
* @param string $hash The webhook hash
*
* @return \Illuminate\View\View
*/
public function webhook(Request $request, $hash)
{
$project = $this->projectRepository->getByHash($hash);
$success = false;
if ($project->servers->where('deploy_code', true)->count() > 0) {
$payload = $this->parseWebhookRequest($request, $project);
if (is_array($payload)) {
$this->deploymentRepository->abortQueued($project->id);
$this->deploymentRepository->create($payload);
$success = true;
}
}
return ['success' => $success];
}