service->driver(); $this->service->update([ 'status' => ServiceStatus::INSTALLING, ]); $this->deployment = $this->service->deployments()->create([ 'status' => DeploymentStatus::PENDING, ]); foreach ($driver->deploymentPlan->steps as $index => $plannedStep) { $step = $this->deployment->steps()->create([ 'order' => $index + 1, 'status' => DeploymentStatus::PENDING, 'script' => $plannedStep->getSafeScript(), 'secrets' => [ 'password' => $this->service->credentials['password'], ], ]); if ($index === 0) { $step->dispatchJob(); } } } public function failed(\Throwable $exception): void { if (isset($this->deployment)) { $this->deployment->update([ 'status' => DeploymentStatus::FAILED, ]); $this->service->update([ 'status' => ServiceStatus::ERROR, ]); } } }