fix(github): changing github app breaks the webhook. it does not anymore

This commit is contained in:
Andras Bacsai
2025-06-21 19:28:38 +02:00
parent 56ee0ea192
commit 3643a388bf
2 changed files with 14 additions and 3 deletions

View File

@@ -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) { if (is_object($this->source) && $this->source->getMorphClass() === \App\Models\GithubApp::class && $this->source->is_public === false) {
$repository = githubApi($this->source, "repos/{$this->customRepository}"); $repository = githubApi($this->source, "repos/{$this->customRepository}");
$data = data_get($repository, 'data'); $data = data_get($repository, 'data');
if (isset($data->id)) { $repository_project_id = data_get($data, 'id');
$repository_project_id = $data->id; if (isset($repository_project_id)) {
if (blank($this->application->repository_project_id) || $this->application->repository_project_id !== $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->repository_project_id = $repository_project_id;
$this->application->save(); $this->application->save();

View File

@@ -111,8 +111,19 @@ class Source extends Component
$this->application->update([ $this->application->update([
'source_id' => $sourceId, 'source_id' => $sourceId,
'source_type' => $sourceType, '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->application->refresh();
$this->getSources(); $this->getSources();
$this->dispatch('success', 'Source updated!'); $this->dispatch('success', 'Source updated!');