diff --git a/web/app/Models/GitRepository.php b/web/app/Models/GitRepository.php index b2d443b..0bf2c19 100644 --- a/web/app/Models/GitRepository.php +++ b/web/app/Models/GitRepository.php @@ -176,6 +176,7 @@ class GitRepository extends Model $gitExecutorShellFileLog = $gitExecutorTempPath . '/git-pull-' . $this->id . '.log'; $gitExecutorContent = view('actions.git.git-executor', [ + 'gitProvider' => $gitSSHUrl['provider'], 'shellFile' => $shellFile, 'shellLog' => $shellLog, 'systemUsername' => $findHostingSubscription->system_username, @@ -228,7 +229,13 @@ class GitRepository extends Model return; } - $cloneUrl = 'git@'.$gitSSHUrl['provider'].':'.$gitSSHUrl['owner'].'/'.$gitSSHUrl['name'].'.git'; + if ($privateKeyFile) { + $cloneUrl = 'git@'.$gitSSHUrl['provider'].':'.$gitSSHUrl['owner'] + .'/'.$gitSSHUrl['name'].'.git'; + } else { + $cloneUrl = 'https://'.$gitSSHUrl['provider'].'/'.$gitSSHUrl['owner'] + .'/'.$gitSSHUrl['name'].'.git'; + } $shellFile = $findDomain->domain_root . '/git/tmp/git-clone-' . $this->id . '.sh'; $shellLog = $findDomain->domain_root . '/git/tmp/git-action-' . $this->id . '.log'; @@ -245,7 +252,7 @@ class GitRepository extends Model 'privateKeyFile' => $privateKeyFile, 'selfFile' => $shellFile, ])->render(); - + file_put_contents($shellFile, $shellContent); @@ -256,6 +263,7 @@ class GitRepository extends Model $gitExecutorShellFileLog = $gitExecutorTempPath . '/git-clone-' . $this->id . '.log'; $gitExecutorContent = view('actions.git.git-executor', [ + 'gitProvider' => $gitSSHUrl['provider'], 'shellFile' => $shellFile, 'shellLog' => $shellLog, 'systemUsername' => $findHostingSubscription->system_username, diff --git a/web/resources/views/actions/git/git-executor.blade.php b/web/resources/views/actions/git/git-executor.blade.php index 2ca7905..148d8a5 100644 --- a/web/resources/views/actions/git/git-executor.blade.php +++ b/web/resources/views/actions/git/git-executor.blade.php @@ -1,3 +1,9 @@ +mkdir -p /home/{{$systemUsername}}/.ssh +ssh-keyscan {{$gitProvider}} >> /home/{{$systemUsername}}/.ssh/known_hosts +chmod 0600 /home/{{$systemUsername}}/.ssh/known_hosts +chown {{$systemUsername}}:{{$systemUsername}} /home/{{$systemUsername}}/.ssh/known_hosts + + chmod +x {{$shellFile}} chown {{$systemUsername}}:{{$systemUsername}} {{$shellFile}} diff --git a/web/resources/views/actions/git/pull-repo-user.blade.php b/web/resources/views/actions/git/pull-repo-user.blade.php index 0744a3f..1ecb66d 100644 --- a/web/resources/views/actions/git/pull-repo-user.blade.php +++ b/web/resources/views/actions/git/pull-repo-user.blade.php @@ -6,10 +6,6 @@ git reset --hard @if($privateKeyFile) -ssh-keyscan {{$gitProvider}} >> /home/{{$systemUsername}}/.ssh/known_hosts -chmod 0600 /home/{{$systemUsername}}/.ssh/known_hosts -chown {{$systemUsername}}:{{$systemUsername}} /home/{{$systemUsername}}/.ssh/known_hosts - git -c core.sshCommand="ssh -i {{$privateKeyFile}}" pull @else