From 3643a388bfb34d28f5857c491fc027235509c96c Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Sat, 21 Jun 2025 19:28:38 +0200 Subject: [PATCH] fix(github): changing github app breaks the webhook. it does not anymore --- app/Jobs/ApplicationDeploymentJob.php | 4 ++-- app/Livewire/Project/Application/Source.php | 13 ++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index eb7686c06..c9b7c9992 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -1381,8 +1381,8 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue if (is_object($this->source) && $this->source->getMorphClass() === \App\Models\GithubApp::class && $this->source->is_public === false) { $repository = githubApi($this->source, "repos/{$this->customRepository}"); $data = data_get($repository, 'data'); - if (isset($data->id)) { - $repository_project_id = $data->id; + $repository_project_id = data_get($data, 'id'); + if (isset($repository_project_id)) { if (blank($this->application->repository_project_id) || $this->application->repository_project_id !== $repository_project_id) { $this->application->repository_project_id = $repository_project_id; $this->application->save(); diff --git a/app/Livewire/Project/Application/Source.php b/app/Livewire/Project/Application/Source.php index e27a550c1..932a302ad 100644 --- a/app/Livewire/Project/Application/Source.php +++ b/app/Livewire/Project/Application/Source.php @@ -111,8 +111,19 @@ class Source extends Component $this->application->update([ 'source_id' => $sourceId, 'source_type' => $sourceType, - 'repository_project_id' => null, ]); + + ['repository' => $customRepository] = $this->application->customRepository(); + $repository = githubApi($this->application->source, "repos/{$customRepository}"); + $data = data_get($repository, 'data'); + $repository_project_id = data_get($data, 'id'); + if (isset($repository_project_id)) { + if ($this->application->repository_project_id !== $repository_project_id) { + $this->application->repository_project_id = $repository_project_id; + $this->application->save(); + } + } + $this->application->refresh(); $this->getSources(); $this->dispatch('success', 'Source updated!');