diff --git a/app/Http/Controllers/Webhook/Github.php b/app/Http/Controllers/Webhook/Github.php index bddfaff92..07b573ab6 100644 --- a/app/Http/Controllers/Webhook/Github.php +++ b/app/Http/Controllers/Webhook/Github.php @@ -410,11 +410,12 @@ public function normal(Request $request) 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); + ApplicationPullRequestUpdateJob::dispatchSync(application: $application, preview: $found, status: ProcessStatus::CLOSED); $found->delete(); - $container_name = generateApplicationContainerName($application, $pull_request_id); - // ray('Stopping container: ' . $container_name); - instant_remote_process(["docker rm -f $container_name"], $application->destination->server); + $return_payloads->push([ 'application' => $application->name, 'status' => 'success', @@ -430,7 +431,6 @@ public function normal(Request $request) } } } - ray($return_payloads); return response($return_payloads); } catch (Exception $e) { ray($e->getMessage()); diff --git a/app/Jobs/ApplicationPullRequestUpdateJob.php b/app/Jobs/ApplicationPullRequestUpdateJob.php index 74f7a7b67..0aedd99a8 100755 --- a/app/Jobs/ApplicationPullRequestUpdateJob.php +++ b/app/Jobs/ApplicationPullRequestUpdateJob.php @@ -31,6 +31,7 @@ public function handle() { try { if ($this->application->is_public_repository()) { + ray('Public repository. Skipping comment update.'); return; } if ($this->status === ProcessStatus::CLOSED) { @@ -59,7 +60,7 @@ public function handle() } } catch (\Throwable $e) { ray($e); - throw $e; + return $e; } } diff --git a/database/migrations/2024_06_06_103938_change_pr_issue_commend_id_type.php b/database/migrations/2024_06_06_103938_change_pr_issue_commend_id_type.php new file mode 100644 index 000000000..c7d71203b --- /dev/null +++ b/database/migrations/2024_06_06_103938_change_pr_issue_commend_id_type.php @@ -0,0 +1,28 @@ +string('pull_request_issue_comment_id')->nullable()->change(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('application_previews', function (Blueprint $table) { + $table->integer('pull_request_issue_comment_id')->nullable()->change(); + }); + } +};