fix: comment id should be string

fix: do not wait for GH response, stop preview before
This commit is contained in:
Andras Bacsai 2024-06-06 12:50:38 +02:00
parent 277d939033
commit 7f052163e3
3 changed files with 34 additions and 5 deletions

View File

@ -410,11 +410,12 @@ public function normal(Request $request)
if ($action === 'closed' || $action === 'close') { if ($action === 'closed' || $action === 'close') {
$found = ApplicationPreview::where('application_id', $application->id)->where('pull_request_id', $pull_request_id)->first(); $found = ApplicationPreview::where('application_id', $application->id)->where('pull_request_id', $pull_request_id)->first();
if ($found) { 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); ApplicationPullRequestUpdateJob::dispatchSync(application: $application, preview: $found, status: ProcessStatus::CLOSED);
$found->delete(); $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([ $return_payloads->push([
'application' => $application->name, 'application' => $application->name,
'status' => 'success', 'status' => 'success',
@ -430,7 +431,6 @@ public function normal(Request $request)
} }
} }
} }
ray($return_payloads);
return response($return_payloads); return response($return_payloads);
} catch (Exception $e) { } catch (Exception $e) {
ray($e->getMessage()); ray($e->getMessage());

View File

@ -31,6 +31,7 @@ public function handle()
{ {
try { try {
if ($this->application->is_public_repository()) { if ($this->application->is_public_repository()) {
ray('Public repository. Skipping comment update.');
return; return;
} }
if ($this->status === ProcessStatus::CLOSED) { if ($this->status === ProcessStatus::CLOSED) {
@ -59,7 +60,7 @@ public function handle()
} }
} catch (\Throwable $e) { } catch (\Throwable $e) {
ray($e); ray($e);
throw $e; return $e;
} }
} }

View File

@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('application_previews', function (Blueprint $table) {
$table->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();
});
}
};