Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix: preview deployments should be stopped properly via gh webhook

Andras Bacsaia3a1ff69e1e2
diff --git a/app/Http/Controllers/Webhook/Github.php b/app/Http/Controllers/Webhook/Github.php
index a030e31ca3..ee51b6e0db 100644
--- a/app/Http/Controllers/Webhook/Github.php
+++ b/app/Http/Controllers/Webhook/Github.php
@@ -340,7 +340,6 @@ class Github extends Controller
return response("Nothing to do. No applications found with branch '$base_branch'.");
}
}
-
foreach ($applications as $application) {
$isFunctional = $application->destination->server->isFunctional();
if (! $isFunctional) {
@@ -432,8 +431,13 @@ class Github extends Controller
if ($action === 'closed' || $action === 'close') {
$found = ApplicationPreview::where('application_id', $application->id)->where('pull_request_id', $pull_request_id)->first();
if ($found) {
- $container_name = generateApplicationContainerName($application, $pull_request_id);
- instant_remote_process(["docker rm -f $container_name"], $application->destination->server);
+ $containers = getCurrentApplicationContainerStatus($application->destination->server, $application->id, $pull_request_id);
+ if ($containers->isNotEmpty()) {
+ $containers->each(function ($container) use ($application) {
+ $container_name = data_get($container, 'Names');
+ instant_remote_process(["docker rm -f $container_name"], $application->destination->server);
+ });
+ }
ApplicationPullRequestUpdateJob::dispatchSync(application: $application, preview: $found, status: ProcessStatus::CLOSED);
$found->delete();