diff --git a/app/Models/GitHook.php b/app/Models/GitHook.php index d9ada2a3e..a3b26c5bc 100755 --- a/app/Models/GitHook.php +++ b/app/Models/GitHook.php @@ -6,6 +6,7 @@ use Database\Factories\GitHookFactory; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Support\Facades\Log; /** * @property int $site_id @@ -64,14 +65,16 @@ public function deployHook(): void ); } - /** - * @throws FailedToDestroyGitHook - */ public function destroyHook(): void { - if ($this->hook_id) { - $this->sourceControl->provider()->destroyHook($this->site->repository, $this->hook_id); + try { + if ($this->hook_id) { + $this->sourceControl->provider()->destroyHook($this->site->repository, $this->hook_id); + } + } catch (FailedToDestroyGitHook $e) { + Log::warning('Failed to destroy git hook', ['error' => $e->getMessage()]); + } finally { + $this->delete(); } - $this->delete(); } } diff --git a/app/Models/Site.php b/app/Models/Site.php index 6942f6d3f..816de8641 100755 --- a/app/Models/Site.php +++ b/app/Models/Site.php @@ -5,7 +5,6 @@ use App\Enums\RedirectStatus; use App\Enums\SiteStatus; use App\Enums\SslStatus; -use App\Exceptions\FailedToDestroyGitHook; use App\Exceptions\SourceControlIsNotConnected; use App\Exceptions\SSHError; use App\Services\PHP\PHP; @@ -112,11 +111,7 @@ public static function boot(): void $site->ssls()->delete(); $site->deployments()->delete(); $site->deploymentScript()->delete(); - try { - $site->gitHook?->destroyHook(); - } catch (FailedToDestroyGitHook) { - $site->refresh()->gitHook?->delete(); - } + $site->gitHook?->destroyHook(); }); static::created(function (Site $site): void { @@ -386,7 +381,6 @@ public function enableAutoDeployment(): void /** * @throws SourceControlIsNotConnected - * @throws FailedToDestroyGitHook */ public function disableAutoDeployment(): void { diff --git a/resources/js/pages/databases/index.tsx b/resources/js/pages/databases/index.tsx index 188d51714..15329439d 100644 --- a/resources/js/pages/databases/index.tsx +++ b/resources/js/pages/databases/index.tsx @@ -40,7 +40,7 @@ export default function Databases() { - +