This commit is contained in:
Bozhidar 2024-10-01 12:57:35 +03:00
parent f8efe85ab6
commit 5d2f2c0c9b
3 changed files with 16 additions and 6 deletions

View file

@ -176,6 +176,7 @@ class GitRepository extends Model
$gitExecutorShellFileLog = $gitExecutorTempPath . '/git-pull-' . $this->id . '.log'; $gitExecutorShellFileLog = $gitExecutorTempPath . '/git-pull-' . $this->id . '.log';
$gitExecutorContent = view('actions.git.git-executor', [ $gitExecutorContent = view('actions.git.git-executor', [
'gitProvider' => $gitSSHUrl['provider'],
'shellFile' => $shellFile, 'shellFile' => $shellFile,
'shellLog' => $shellLog, 'shellLog' => $shellLog,
'systemUsername' => $findHostingSubscription->system_username, 'systemUsername' => $findHostingSubscription->system_username,
@ -228,7 +229,13 @@ class GitRepository extends Model
return; 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'; $shellFile = $findDomain->domain_root . '/git/tmp/git-clone-' . $this->id . '.sh';
$shellLog = $findDomain->domain_root . '/git/tmp/git-action-' . $this->id . '.log'; $shellLog = $findDomain->domain_root . '/git/tmp/git-action-' . $this->id . '.log';
@ -256,6 +263,7 @@ class GitRepository extends Model
$gitExecutorShellFileLog = $gitExecutorTempPath . '/git-clone-' . $this->id . '.log'; $gitExecutorShellFileLog = $gitExecutorTempPath . '/git-clone-' . $this->id . '.log';
$gitExecutorContent = view('actions.git.git-executor', [ $gitExecutorContent = view('actions.git.git-executor', [
'gitProvider' => $gitSSHUrl['provider'],
'shellFile' => $shellFile, 'shellFile' => $shellFile,
'shellLog' => $shellLog, 'shellLog' => $shellLog,
'systemUsername' => $findHostingSubscription->system_username, 'systemUsername' => $findHostingSubscription->system_username,

View file

@ -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}} chmod +x {{$shellFile}}
chown {{$systemUsername}}:{{$systemUsername}} {{$shellFile}} chown {{$systemUsername}}:{{$systemUsername}} {{$shellFile}}

View file

@ -6,10 +6,6 @@ git reset --hard
@if($privateKeyFile) @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 git -c core.sshCommand="ssh -i {{$privateKeyFile}}" pull
@else @else