mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-08 09:22:34 +00:00
refactoring
This commit is contained in:
@ -4,7 +4,7 @@
|
||||
|
||||
use App\Jobs\Job;
|
||||
use App\Models\Site;
|
||||
use App\SSHCommands\CloneRepositoryCommand;
|
||||
use App\SSHCommands\Website\CloneRepositoryCommand;
|
||||
use Throwable;
|
||||
|
||||
class CloneRepository extends Job
|
||||
@ -25,7 +25,8 @@ public function handle(): void
|
||||
new CloneRepositoryCommand(
|
||||
$this->site->full_repository_url,
|
||||
$this->site->path,
|
||||
$this->site->branch
|
||||
$this->site->branch,
|
||||
$this->site->ssh_key_name
|
||||
),
|
||||
'clone-repository',
|
||||
$this->site->id
|
||||
|
@ -5,7 +5,7 @@
|
||||
use App\Exceptions\ComposerInstallFailed;
|
||||
use App\Jobs\Job;
|
||||
use App\Models\Site;
|
||||
use App\SSHCommands\ComposerInstallCommand;
|
||||
use App\SSHCommands\Website\ComposerInstallCommand;
|
||||
use Throwable;
|
||||
|
||||
class ComposerInstall extends Job
|
||||
|
@ -7,7 +7,7 @@
|
||||
use App\Helpers\SSH;
|
||||
use App\Jobs\Job;
|
||||
use App\Models\Deployment;
|
||||
use App\SSHCommands\RunScript;
|
||||
use App\SSHCommands\System\RunScript;
|
||||
use Throwable;
|
||||
|
||||
class Deploy extends Job
|
||||
|
@ -5,7 +5,7 @@
|
||||
use App\Events\Broadcast;
|
||||
use App\Jobs\Job;
|
||||
use App\Models\Site;
|
||||
use App\SSHCommands\EditFileCommand;
|
||||
use App\SSHCommands\System\EditFileCommand;
|
||||
use Throwable;
|
||||
|
||||
class DeployEnv extends Job
|
||||
|
42
app/Jobs/Site/DeployKey.php
Executable file
42
app/Jobs/Site/DeployKey.php
Executable file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Site;
|
||||
|
||||
use App\Jobs\Job;
|
||||
use App\Models\Site;
|
||||
use App\SSHCommands\System\GenerateSshKeyCommand;
|
||||
use App\SSHCommands\System\ReadSshKeyCommand;
|
||||
use Throwable;
|
||||
|
||||
class DeployKey extends Job
|
||||
{
|
||||
protected Site $site;
|
||||
|
||||
public function __construct(Site $site)
|
||||
{
|
||||
$this->site = $site;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
$this->site->server->ssh()->exec(
|
||||
new GenerateSshKeyCommand($this->site->ssh_key_name),
|
||||
'generate-ssh-key',
|
||||
$this->site->id
|
||||
);
|
||||
$this->site->ssh_key = $this->site->server->ssh()->exec(
|
||||
new ReadSshKeyCommand($this->site->ssh_key_name),
|
||||
'read-public-key',
|
||||
$this->site->id
|
||||
);
|
||||
$this->site->save();
|
||||
$this->site->sourceControl()->provider()->deployKey(
|
||||
$this->site->domain.'-key-' . $this->site->id,
|
||||
$this->site->repository,
|
||||
$this->site->ssh_key
|
||||
);
|
||||
}
|
||||
}
|
@ -7,7 +7,7 @@
|
||||
use App\Models\Database;
|
||||
use App\Models\DatabaseUser;
|
||||
use App\Models\Site;
|
||||
use App\SSHCommands\InstallWordpressCommand;
|
||||
use App\SSHCommands\Wordpress\InstallWordpressCommand;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Throwable;
|
||||
|
@ -5,7 +5,7 @@
|
||||
use App\Events\Broadcast;
|
||||
use App\Jobs\Job;
|
||||
use App\Models\Site;
|
||||
use App\SSHCommands\UpdateBranchCommand;
|
||||
use App\SSHCommands\Website\UpdateBranchCommand;
|
||||
use Throwable;
|
||||
|
||||
class UpdateBranch extends Job
|
||||
|
@ -1,41 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Site;
|
||||
|
||||
use App\Jobs\Job;
|
||||
use App\Models\Site;
|
||||
use App\Models\SourceControl;
|
||||
use Throwable;
|
||||
|
||||
class UpdateSourceControlsRemote extends Job
|
||||
{
|
||||
protected SourceControl $sourceControl;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(SourceControl $sourceControl)
|
||||
{
|
||||
$this->sourceControl = $sourceControl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
$sites = Site::query()
|
||||
->where('user_id', $this->sourceControl->user_id)
|
||||
->where('source_control', $this->sourceControl->provider)
|
||||
->get();
|
||||
foreach ($sites as $site) {
|
||||
$site->server->ssh()->exec(
|
||||
'cd '.$site->path.' && git remote set-url origin '.$site->full_repository_url
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user