This commit is contained in:
Bozhidar 2024-09-19 18:10:55 +03:00
parent 3839d5cb98
commit daf5998568
3 changed files with 17 additions and 10 deletions

View file

@ -47,6 +47,10 @@ class GitRepositoryResource extends Resource
return $table
->columns([
Tables\Columns\TextColumn::make('id')
->label('#')
->sortable(),
Tables\Columns\TextColumn::make('domain.domain'),
// Tables\Columns\TextColumn::make('name')

View file

@ -148,8 +148,11 @@ class GitRepository extends Model
$cloneUrl = 'git@'.$gitSSHUrl['provider'].':'.$gitSSHUrl['owner'].'/'.$gitSSHUrl['name'].'.git';
$shellFile = '/tmp/git-pull-' . $this->id . '.sh';
$shellLog = '/tmp/git-pull-' . $this->id . '.log';
$shellFile = $findDomain->domain_root . '/git/tmp/git-pull-' . $this->id . '.sh';
$shellLog = $findDomain->domain_root . '/git/tmp/git-pull-' . $this->id . '.log';
shell_exec('mkdir -p ' . dirname($shellFile));
shell_exec('chown '.$findHostingSubscription->system_username.':'.$findHostingSubscription->system_username.' -R ' . dirname(dirname($shellFile)));
$shellContent = view('actions.git.pull-repo', [
'gitProvider' => $gitSSHUrl['provider'],
@ -158,12 +161,15 @@ class GitRepository extends Model
'cloneUrl' => $cloneUrl,
'projectDir' => $projectDir,
'privateKeyFile' => $privateKeyFile,
'selfFile' => $shellFile,
])->render();
file_put_contents($shellFile, $shellContent);
shell_exec('chmod +x ' . $shellFile);
shell_exec('bash '.$shellFile.' >> ' . $shellLog . ' &');
shell_exec('chown '.$findHostingSubscription->system_username.':'.$findHostingSubscription->system_username.' ' . $shellFile);
shell_exec('su -m ' . $findHostingSubscription->system_username . ' -c "bash '.$shellFile.' >> ' . $shellLog . ' &"');
}

View file

@ -1,6 +1,6 @@
echo "Pull started at {{ date('Y-m-d H:i:s') }}"
su -m {{$systemUsername}} -c "export HOME=/home/{{$systemUsername}}"
cd {{$projectDir}}
@if($privateKeyFile)
@ -8,15 +8,12 @@ ssh-keyscan {{$gitProvider}} >> /home/{{$systemUsername}}/.ssh/known_hosts
chmod 0600 /home/{{$systemUsername}}/.ssh/known_hosts
chown {{$systemUsername}}:{{$systemUsername}} /home/{{$systemUsername}}/.ssh/known_hosts
su -m {{$systemUsername}} -c 'cd {{$projectDir}} && git -c core.sshCommand="ssh -i {{$privateKeyFile}}" pull'
git -c core.sshCommand="ssh -i {{$privateKeyFile}}" pull
@else
su -m {{$systemUsername}} -c 'cd {{$projectDir}} && git pull'
git pull
@endif
phyre-php /usr/local/phyre/web/artisan git-repository:mark-as-pulled {{$gitRepositoryId}}
rm -rf /tmp/git-pull-{{$gitRepositoryId}}.sh
rm -rf {{$selfFile}}