Refactor webhook handling logic to remove duplicate code and improve readability

This commit is contained in:
Andras Bacsai 2024-01-29 16:31:10 +01:00
parent 919e88afb4
commit 9a127bdc80

View File

@ -277,14 +277,6 @@
]); ]);
} }
foreach ($applications as $application) { 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'); $webhook_secret = data_get($application, 'manual_webhook_secret_bitbucket');
$payload = request()->getContent(); $payload = request()->getContent();
@ -310,7 +302,7 @@
continue; continue;
} }
if ($x_bitbucket_event === 'repo:push') { if ($x_bitbucket_event === 'repo:push') {
if ($application->isPRDeployable()) { if ($application->isDeployable()) {
ray('Deploying ' . $application->name . ' with branch ' . $branch); ray('Deploying ' . $application->name . ' with branch ' . $branch);
$deployment_uuid = new Cuid2(7); $deployment_uuid = new Cuid2(7);
queue_application_deployment( queue_application_deployment(
@ -328,7 +320,7 @@
$return_payloads->push([ $return_payloads->push([
'application' => $application->name, 'application' => $application->name,
'status' => 'failed', 'status' => 'failed',
'message' => 'Preview deployments disabled.', 'message' => 'Auto deployment disabled.',
]); ]);
} }
} }