Refactor deployment logic in Github webhook controller
This commit is contained in:
parent
132807b55d
commit
a198bfc5c0
@ -204,7 +204,6 @@ public function manual(Request $request)
|
|||||||
}
|
}
|
||||||
public function normal(Request $request)
|
public function normal(Request $request)
|
||||||
{
|
{
|
||||||
ray('asdf');
|
|
||||||
try {
|
try {
|
||||||
$return_payloads = collect([]);
|
$return_payloads = collect([]);
|
||||||
$id = null;
|
$id = null;
|
||||||
@ -303,9 +302,10 @@ public function normal(Request $request)
|
|||||||
$isFunctional = $application->destination->server->isFunctional();
|
$isFunctional = $application->destination->server->isFunctional();
|
||||||
if (!$isFunctional) {
|
if (!$isFunctional) {
|
||||||
$return_payloads->push([
|
$return_payloads->push([
|
||||||
'application' => $application->name,
|
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => 'Server is not functional.',
|
'message' => 'Server is not functional.',
|
||||||
|
'application_uuid' => $application->uuid,
|
||||||
|
'application_name' => $application->name,
|
||||||
]);
|
]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -313,13 +313,15 @@ public function normal(Request $request)
|
|||||||
if ($application->isDeployable()) {
|
if ($application->isDeployable()) {
|
||||||
$watch_files_trigger = $application->watchPathCheck($changed_files);
|
$watch_files_trigger = $application->watchPathCheck($changed_files);
|
||||||
if (!$watch_files_trigger) {
|
if (!$watch_files_trigger) {
|
||||||
|
$paths = str($application->watch_paths)->explode("\n");
|
||||||
$return_payloads->push([
|
$return_payloads->push([
|
||||||
'application' => $application->name,
|
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => 'Watch paths does not have the changed files. Deployment ignored.',
|
'message' => 'Changed files do not match watch paths. Ignoring deployment.',
|
||||||
|
'application_uuid' => $application->uuid,
|
||||||
|
'application_name' => $application->name,
|
||||||
'details' => [
|
'details' => [
|
||||||
'changed_files' => $changed_files,
|
'changed_files' => $changed_files,
|
||||||
'watch_paths' => $application->watch_paths,
|
'watch_paths' => $paths,
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
@ -332,16 +334,18 @@ public function normal(Request $request)
|
|||||||
is_webhook: true,
|
is_webhook: true,
|
||||||
);
|
);
|
||||||
$return_payloads->push([
|
$return_payloads->push([
|
||||||
'application' => $application->name,
|
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'Deployment queued.',
|
'message' => 'Deployment queued.',
|
||||||
|
'application_uuid' => $application->uuid,
|
||||||
|
'application_name' => $application->name,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$return_payloads->push([
|
$return_payloads->push([
|
||||||
'application' => $application->name,
|
|
||||||
'status' => 'failed',
|
'status' => 'failed',
|
||||||
'message' => 'Deployments disabled.',
|
'message' => 'Deployments disabled.',
|
||||||
|
'application_uuid' => $application->uuid,
|
||||||
|
'application_name' => $application->name,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user