mirror of
https://github.com/vitodeploy/vito.git
synced 2025-04-21 02:41:36 +00:00
49 lines
940 B
PHP
49 lines
940 B
PHP
<?php
|
|
|
|
namespace App\Jobs\Site;
|
|
|
|
use App\Events\Broadcast;
|
|
use App\Jobs\Job;
|
|
use App\Models\Site;
|
|
use App\SSHCommands\System\EditFileCommand;
|
|
use Throwable;
|
|
|
|
class DeployEnv 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 EditFileCommand(
|
|
$this->site->path.'/.env',
|
|
$this->site->env
|
|
),
|
|
'update-env',
|
|
$this->site->id
|
|
);
|
|
event(
|
|
new Broadcast('deploy-site-env-finished', [
|
|
'site' => $this->site,
|
|
])
|
|
);
|
|
}
|
|
|
|
public function failed(): void
|
|
{
|
|
event(
|
|
new Broadcast('deploy-site-env-failed', [
|
|
'site' => $this->site,
|
|
])
|
|
);
|
|
}
|
|
}
|