From 9a127bdc80cb6361bb2438c68beab40c5bf5963b Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Mon, 29 Jan 2024 16:31:10 +0100 Subject: [PATCH] Refactor webhook handling logic to remove duplicate code and improve readability --- routes/webhooks.php | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/routes/webhooks.php b/routes/webhooks.php index 515b90d84..c831b8818 100644 --- a/routes/webhooks.php +++ b/routes/webhooks.php @@ -277,14 +277,6 @@ Route::post('/source/bitbucket/events/manual', function () { ]); } foreach ($applications as $application) { - if (!$application->isPRDeployable()) { - $return_payloads->push([ - 'application' => $application->name, - 'status' => 'failed', - 'message' => 'Preview deployments disabled.', - ]); - continue; - } $webhook_secret = data_get($application, 'manual_webhook_secret_bitbucket'); $payload = request()->getContent(); @@ -310,7 +302,7 @@ Route::post('/source/bitbucket/events/manual', function () { continue; } if ($x_bitbucket_event === 'repo:push') { - if ($application->isPRDeployable()) { + if ($application->isDeployable()) { ray('Deploying ' . $application->name . ' with branch ' . $branch); $deployment_uuid = new Cuid2(7); queue_application_deployment( @@ -328,7 +320,7 @@ Route::post('/source/bitbucket/events/manual', function () { $return_payloads->push([ 'application' => $application->name, 'status' => 'failed', - 'message' => 'Preview deployments disabled.', + 'message' => 'Auto deployment disabled.', ]); } }