Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
bobimicroweber committed Oct 1, 2024
1 parent f8efe85 commit 5d2f2c0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
12 changes: 10 additions & 2 deletions web/app/Models/GitRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ public function pull()
$gitExecutorShellFileLog = $gitExecutorTempPath . '/git-pull-' . $this->id . '.log';

$gitExecutorContent = view('actions.git.git-executor', [
'gitProvider' => $gitSSHUrl['provider'],
'shellFile' => $shellFile,
'shellLog' => $shellLog,
'systemUsername' => $findHostingSubscription->system_username,
Expand Down Expand Up @@ -228,7 +229,13 @@ public function clone()
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';
Expand All @@ -245,7 +252,7 @@ public function clone()
'privateKeyFile' => $privateKeyFile,
'selfFile' => $shellFile,
])->render();

file_put_contents($shellFile, $shellContent);


Expand All @@ -256,6 +263,7 @@ public function clone()
$gitExecutorShellFileLog = $gitExecutorTempPath . '/git-clone-' . $this->id . '.log';

$gitExecutorContent = view('actions.git.git-executor', [
'gitProvider' => $gitSSHUrl['provider'],
'shellFile' => $shellFile,
'shellLog' => $shellLog,
'systemUsername' => $findHostingSubscription->system_username,
Expand Down
6 changes: 6 additions & 0 deletions web/resources/views/actions/git/git-executor.blade.php
Original file line number Diff line number Diff line change
@@ -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}}

Expand Down
4 changes: 0 additions & 4 deletions web/resources/views/actions/git/pull-repo-user.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@

@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
Expand Down

0 comments on commit 5d2f2c0

Please sign in to comment.