fix(previews): clean up closed PR previews after update failures (#10180)

This commit is contained in:
Andras Bacsai
2026-06-12 20:08:34 +02:00
committed by GitHub
2 changed files with 89 additions and 7 deletions
+17 -7
View File
@@ -14,6 +14,7 @@ use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Throwable;
use Visus\Cuid2\Cuid2;
class ProcessGithubPullRequestWebhook implements ShouldBeEncrypted, ShouldQueue
@@ -71,16 +72,25 @@ class ProcessGithubPullRequestWebhook implements ShouldBeEncrypted, ShouldQueue
->first();
if ($found) {
ApplicationPullRequestUpdateJob::dispatchSync(
application: $application,
preview: $found,
status: ProcessStatus::CLOSED
);
CleanupPreviewDeployment::run($application, $this->pullRequestId, $found);
try {
$this->dispatchPullRequestClosedUpdate($application, $found);
} catch (Throwable $e) {
report($e);
} finally {
CleanupPreviewDeployment::run($application, $this->pullRequestId, $found);
}
}
}
protected function dispatchPullRequestClosedUpdate(Application $application, ApplicationPreview $preview): void
{
ApplicationPullRequestUpdateJob::dispatchSync(
application: $application,
preview: $preview,
status: ProcessStatus::CLOSED
);
}
private function handleOpenAction(Application $application, ?GithubApp $githubApp): void
{
if (! $application->isPRDeployable()) {