diff --git a/web/Modules/Customer/App/Filament/Resources/GitRepositoryResource.php b/web/Modules/Customer/App/Filament/Resources/GitRepositoryResource.php index a1e262d..7495185 100644 --- a/web/Modules/Customer/App/Filament/Resources/GitRepositoryResource.php +++ b/web/Modules/Customer/App/Filament/Resources/GitRepositoryResource.php @@ -33,6 +33,11 @@ class GitRepositoryResource extends Resource ->required() ->columnSpanFull(), + Forms\Components\Select::make('git_ssh_key_id') + ->label('SSH Key') + ->options(fn () => \App\Models\GitSshKey::pluck('name', 'id')) + ->columnSpanFull(), + ]); } diff --git a/web/app/Models/GitRepository.php b/web/app/Models/GitRepository.php index 1e3a5ab..7bb62c0 100644 --- a/web/app/Models/GitRepository.php +++ b/web/app/Models/GitRepository.php @@ -71,10 +71,12 @@ class GitRepository extends Model return $this->belongsTo(Domain::class); } - private function _getSSHKey($findHostingSubscription) + private function _getSSHKey($gitSshKeyId, $findHostingSubscription) { + $gitSSHKey = GitSshKey::where('id', $gitSshKeyId) + ->where('hosting_subscription_id', $findHostingSubscription->id) + ->first(); - $gitSSHKey = GitSshKey::find($this->git_ssh_key_id); if ($gitSSHKey) { $sshPath = '/home/'.$findHostingSubscription->system_username .'/.ssh'; $privateKeyFile = $sshPath.'/id_rsa_'. $gitSSHKey->id; @@ -131,12 +133,11 @@ class GitRepository extends Model $projectDir = $findDomain->domain_root . '/' . $this->dir; $privateKeyFile = null; - $getSSHKey = $this->_getSSHKey($findHostingSubscription); + $getSSHKey = $this->_getSSHKey($this->git_ssh_key_id, $findHostingSubscription); if (isset($getSSHKey['privateKeyFile'])) { $privateKeyFile = $getSSHKey['privateKeyFile']; } - $gitSSHUrl = GitClient::parseGitUrl($this->url); if (!isset($gitSSHUrl['provider'])) { $this->status = self::STATUS_FAILED; @@ -190,7 +191,7 @@ class GitRepository extends Model $projectDir = $findDomain->domain_root . '/' . $this->dir; $privateKeyFile = null; - $getSSHKey = $this->_getSSHKey($findHostingSubscription); + $getSSHKey = $this->_getSSHKey($this->git_ssh_key_id, $findHostingSubscription); if (isset($getSSHKey['privateKeyFile'])) { $privateKeyFile = $getSSHKey['privateKeyFile']; } diff --git a/web/resources/views/actions/git/clone-repo.blade.php b/web/resources/views/actions/git/clone-repo.blade.php index dba9768..fc0aad2 100644 --- a/web/resources/views/actions/git/clone-repo.blade.php +++ b/web/resources/views/actions/git/clone-repo.blade.php @@ -18,4 +18,4 @@ su -m {{$systemUsername}} -c 'git clone {{$cloneUrl}} {{$projectDir}}' phyre-php /usr/local/phyre/web/artisan git-repository:mark-as-cloned {{$gitRepositoryId}} -# rm -rf /tmp/git-clone-{{$gitRepositoryId}}.sh +rm -rf /tmp/git-clone-{{$gitRepositoryId}}.sh