Skip to content

Commit

Permalink
fix: comment id should be string
Browse files Browse the repository at this point in the history
fix: do not wait for GH response, stop preview before
  • Loading branch information
andrasbacsai committed Jun 6, 2024
1 parent 277d939 commit 7f05216
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
8 changes: 4 additions & 4 deletions app/Http/Controllers/Webhook/Github.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
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);

ApplicationPullRequestUpdateJob::dispatchSync(application: $application, preview: $found, status: ProcessStatus::CLOSED);
$found->delete();

$return_payloads->push([
'application' => $application->name,
'status' => 'success',
Expand All @@ -430,7 +431,6 @@ public function normal(Request $request)
}
}
}
ray($return_payloads);
return response($return_payloads);
} catch (Exception $e) {
ray($e->getMessage());
Expand Down
3 changes: 2 additions & 1 deletion app/Jobs/ApplicationPullRequestUpdateJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -59,7 +60,7 @@ public function handle()
}
} catch (\Throwable $e) {
ray($e);
throw $e;
return $e;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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();
});
}
};

0 comments on commit 7f05216

Please sign in to comment.