releases()->create([ 'pipeline_id' => $pipeline->getKey(), 'version' => $attributes['version'] ?? now()->format('YmdHis').'-'.Str::lower(Str::random(6)), 'commit_hash' => $attributes['commit_hash'] ?? null, 'status' => $pipeline->requires_approval ? 'awaiting_approval' : 'pending', 'requested_by' => $attributes['requested_by'] ?? null, 'metadata' => $attributes['metadata'] ?? [], ]); foreach ($pipeline->steps as $position => $step) { $release->steps()->create(['name' => $step['name'] ?? 'Step '.($position + 1), 'position' => $position]); } return $release->load('steps'); }); } public function execute(DeploymentRelease $release): DeploymentRelease { abort_unless(config('clouddevops.allow_execution'), 403, 'Deployment execution is disabled.'); $release->update(['status' => 'running', 'started_at' => now()]); return $release->refresh(); } }