mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-02 14:36:17 +00:00
refactoring
This commit is contained in:
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
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user