Skip to content

Commit 0d8cc19

Browse files
committed
fix: deleting application should delete preview deployments
1 parent a3a1ff6 commit 0d8cc19

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

app/Actions/Application/StopApplication.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class StopApplication
99
{
1010
use AsAction;
1111

12-
public function handle(Application $application)
12+
public function handle(Application $application, bool $previewDeployments = false)
1313
{
1414
if ($application->destination->server->isSwarm()) {
1515
instant_remote_process(["docker stack rm {$application->uuid}"], $application->destination->server);
@@ -26,7 +26,12 @@ public function handle(Application $application)
2626
if (! $server->isFunctional()) {
2727
return 'Server is not functional';
2828
}
29-
$containers = getCurrentApplicationContainerStatus($server, $application->id, 0);
29+
if ($previewDeployments) {
30+
$containers = getCurrentApplicationContainerStatus($server, $application->id, includePullrequests: true);
31+
} else {
32+
$containers = getCurrentApplicationContainerStatus($server, $application->id, 0);
33+
}
34+
ray($containers);
3035
if ($containers->count() > 0) {
3136
foreach ($containers as $container) {
3237
$containerName = data_get($container, 'Names');

app/Jobs/DeleteResourceJob.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function handle()
4040
switch ($this->resource->type()) {
4141
case 'application':
4242
$persistentStorages = $this->resource?->persistentStorages()?->get();
43-
StopApplication::run($this->resource);
43+
StopApplication::run($this->resource, previewDeployments: true);
4444
break;
4545
case 'standalone-postgresql':
4646
case 'standalone-redis':

0 commit comments

Comments
 (0)