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.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
fix(github): skip opened PR previews with skip ci
Andras Bacsai3f960d94c350
diff --git a/app/Jobs/ProcessGithubPullRequestWebhook.php b/app/Jobs/ProcessGithubPullRequestWebhook.phpindex 666888a579..5186a58bbf 100644--- a/app/Jobs/ProcessGithubPullRequestWebhook.php+++ b/app/Jobs/ProcessGithubPullRequestWebhook.php@@ -101,7 +101,7 @@ class ProcessGithubPullRequestWebhook implements ShouldBeEncrypted, ShouldQueue$repo = $repository_parts[1] ?? '';$headCommitMessage = null;- if ($this->action === 'synchronize') {+ if ($this->action === 'opened' || $this->action === 'synchronize' || $this->action === 'reopened') {$headCommitMessage = getGithubCommitMessage($githubApp, $owner, $repo, $this->commitSha);}diff --git a/tests/Feature/ProcessGithubPullRequestWebhookTest.php b/tests/Feature/ProcessGithubPullRequestWebhookTest.phpindex 557e42ce89..bd217396c3 100644--- a/tests/Feature/ProcessGithubPullRequestWebhookTest.php+++ b/tests/Feature/ProcessGithubPullRequestWebhookTest.php@@ -108,3 +108,50 @@ it('skips a synchronized GitHub pull request preview when the head commit messagHttp::assertSent(fn (Request $request): bool => $request->url() === 'https://api.github.com/repos/example/repo/commits/after-sha');});++it('skips a GitHub pull request preview when the opened or reopened head commit message contains skip ci', function (string $action) {+ Queue::fake();++ $this->application->settings->update([+ 'is_preview_deployments_enabled' => true,+ ]);++ $githubApp = GithubApp::create([+ 'name' => 'Public GitHub',+ 'api_url' => 'https://api.github.com',+ 'html_url' => 'https://github.com',+ 'is_public' => true,+ 'team_id' => $this->team->id,+ ]);++ Http::fake([+ 'https://api.github.com/repos/example/repo/commits/head-sha' => Http::response([+ 'commit' => [+ 'message' => 'docs: fix typo [skip ci]',+ ],+ ]),+ 'https://api.github.com/repos/example/repo/pulls/42/files' => Http::response([]),+ ]);++ $job = new ProcessGithubPullRequestWebhook(+ applicationId: $this->application->id,+ githubAppId: $githubApp->id,+ action: $action,+ pullRequestId: 42,+ pullRequestHtmlUrl: 'https://github.com/example/repo/pull/42',+ pullRequestTitle: 'Add feature',+ beforeSha: null,+ afterSha: null,+ commitSha: 'head-sha',+ authorAssociation: 'OWNER',+ fullName: 'example/repo',+ );++ $job->handle();++ expect(ApplicationPreview::where('application_id', $this->application->id)->where('pull_request_id', 42)->exists())->toBeFalse()+ ->and(ApplicationDeploymentQueue::where('application_id', $this->application->id)->where('pull_request_id', 42)->exists())->toBeFalse();++ Http::assertSent(fn (Request $request): bool => $request->url() === 'https://api.github.com/repos/example/repo/commits/head-sha');+ Http::assertNotSent(fn (Request $request): bool => $request->url() === 'https://api.github.com/repos/example/repo/pulls/42/files');+})->with(['opened', 'reopened']);