Skip to content

Commit 20e2f31

Browse files
committed
Check status for existing deployments
1 parent 513dc66 commit 20e2f31

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

packages/cli-v3/src/commands/deploy.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,13 +757,22 @@ async function initializeOrAttachDeployment(
757757
);
758758
}
759759

760-
const { imageReference } = existingDeploymentOrError.data;
760+
const { imageReference, status } = existingDeploymentOrError.data;
761761
if (!imageReference) {
762762
// this is just an artifact of our current DB schema
763763
// `imageReference` is stored as nullable, but it should always exist
764764
throw new Error("Existing deployment does not have an image reference");
765765
}
766766

767+
if (
768+
status === "CANCELED" ||
769+
status === "FAILED" ||
770+
status === "TIMED_OUT" ||
771+
status === "DEPLOYED"
772+
) {
773+
throw new Error(`Existing deployment is in unexpected state: ${status}`);
774+
}
775+
767776
return {
768777
...existingDeploymentOrError.data,
769778
imageTag: imageReference,

0 commit comments

Comments
 (0)