From 084b6aa35ec1b28570f479cfd7b067844c446511 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 26 Nov 2026 19:10:09 +0000 Subject: [PATCH] Expose why Laravel Cloud started a deployment The API now returns `trigger` and `trigger_reference` on every deployment: `patch` (and the CVE it fixes) when Laravel Cloud redeployed the current code on a patched image, null when a person or automation started it. The Deployment DTO dropped both, so `--json` and `--fields` couldn't surface them. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01T1Sq4WiUrLvGeKw2bhP3DT --- app/Dto/Deployment.php | 4 ++++ tests/Unit/DeploymentDtoTest.php | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/app/Dto/Deployment.php b/app/Dto/Deployment.php index 1b5bc180..1bf00b42 100644 --- a/app/Dto/Deployment.php +++ b/app/Dto/Deployment.php @@ -33,6 +33,8 @@ public function __construct( public readonly bool $usesOctane = false, public readonly bool $usesHibernation = false, public readonly ?int $hibernationWakeUpInterval = null, + public readonly ?string $trigger = null, + public readonly ?string $triggerReference = null, public readonly ?Environment $environment = null, public readonly ?User $initiator = null, ) { @@ -124,6 +126,8 @@ public static function createFromResponse(array $response): self 'usesOctane' => $attributes['uses_octane'] ?? false, 'usesHibernation' => $attributes['uses_hibernation'] ?? false, 'hibernationWakeUpInterval' => $attributes['hibernation_wake_up_interval'] ?? null, + 'trigger' => $attributes['trigger'] ?? null, + 'triggerReference' => $attributes['trigger_reference'] ?? null, ]; if (isset($relationships['environment']['data'])) { diff --git a/tests/Unit/DeploymentDtoTest.php b/tests/Unit/DeploymentDtoTest.php index 4fc10e57..93c31946 100644 --- a/tests/Unit/DeploymentDtoTest.php +++ b/tests/Unit/DeploymentDtoTest.php @@ -23,6 +23,8 @@ 'hibernation_wake_up_interval' => 30, 'started_at' => '2026-10-01T12:00:00.000000Z', 'finished_at' => '2026-10-01T12:02:00.000000Z', + 'trigger' => null, + 'trigger_reference' => null, ], ], ]); @@ -32,5 +34,28 @@ ->and($deployment->commitHash)->toBe('abc1234') ->and($deployment->commitMessage)->toBe('Fix bug') ->and($deployment->commitAuthor)->toBe('Taylor') + ->and($deployment->trigger)->toBeNull() + ->and($deployment->triggerReference)->toBeNull() ->and($deployment->toArray())->not->toHaveKeys(['createdAt', 'updatedAt']); }); + +it('maps why Laravel Cloud started a deployment itself', function () { + $deployment = Deployment::createFromResponse([ + 'data' => [ + 'id' => 'deploy-2', + 'type' => 'deployments', + 'attributes' => [ + 'status' => 'deployment.succeeded', + 'trigger' => 'patch', + 'trigger_reference' => 'CVE-2026-12345', + ], + ], + ]); + + expect($deployment->trigger)->toBe('patch') + ->and($deployment->triggerReference)->toBe('CVE-2026-12345') + ->and($deployment->toArray())->toMatchArray([ + 'trigger' => 'patch', + 'triggerReference' => 'CVE-2026-12345', + ]); +});