mirror of
https://github.com/vitodeploy/vito.git
synced 2025-04-21 02:41:36 +00:00
load the actual env from the server
This commit is contained in:
parent
9db310a06b
commit
682da0d6d5
0
app/Actions/Site/UpdateEnv.php
Executable file → Normal file
0
app/Actions/Site/UpdateEnv.php
Executable file → Normal file
@ -14,11 +14,11 @@ class Env extends Component
|
||||
|
||||
public Site $site;
|
||||
|
||||
public string $env;
|
||||
public string $env = 'Loading...';
|
||||
|
||||
public function mount(): void
|
||||
public function loadEnv(): void
|
||||
{
|
||||
$this->env = $this->site->env;
|
||||
$this->env = $this->site->getEnv();
|
||||
}
|
||||
|
||||
public function save(): void
|
||||
|
@ -26,9 +26,7 @@ public function handle(): void
|
||||
new EditFileCommand(
|
||||
$this->site->path.'/.env',
|
||||
$this->site->env
|
||||
),
|
||||
'update-env',
|
||||
$this->site->id
|
||||
)
|
||||
);
|
||||
event(
|
||||
new Broadcast('deploy-site-env-finished', [
|
||||
|
@ -15,6 +15,7 @@
|
||||
use App\Jobs\Site\UpdateBranch;
|
||||
use App\Notifications\SiteInstallationFailed;
|
||||
use App\Notifications\SiteInstallationSucceed;
|
||||
use App\SSHCommands\Website\GetEnvCommand;
|
||||
use Exception;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@ -442,4 +443,13 @@ public function isReady(): bool
|
||||
{
|
||||
return $this->status === SiteStatus::READY;
|
||||
}
|
||||
|
||||
public function getEnv(): string
|
||||
{
|
||||
return $this->server->ssh()->exec(
|
||||
new GetEnvCommand(
|
||||
$this->domain
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
26
app/SSHCommands/Website/GetEnvCommand.php
Executable file
26
app/SSHCommands/Website/GetEnvCommand.php
Executable file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\SSHCommands\Website;
|
||||
|
||||
use App\SSHCommands\Command;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
class GetEnvCommand extends Command
|
||||
{
|
||||
public function __construct(
|
||||
protected string $domain
|
||||
) {
|
||||
}
|
||||
|
||||
public function file(): string
|
||||
{
|
||||
return File::get(resource_path('commands/website/get-env.sh'));
|
||||
}
|
||||
|
||||
public function content(): string
|
||||
{
|
||||
return str($this->file())
|
||||
->replace('__domain__', $this->domain)
|
||||
->toString();
|
||||
}
|
||||
}
|
1
resources/commands/website/get-env.sh
Normal file
1
resources/commands/website/get-env.sh
Normal file
@ -0,0 +1 @@
|
||||
[ -f /home/vito/__domain__/.env ] && cat /home/vito/__domain__/.env
|
@ -7,7 +7,7 @@
|
||||
|
||||
<div class="mt-6">
|
||||
<x-input-label for="env" :value="__('.env')" />
|
||||
<x-textarea wire:model="env" rows="10" id="env" name="env" class="mt-1 w-full" />
|
||||
<x-textarea id="env" wire:init="loadEnv" wire:model="env" rows="10" class="mt-1 block w-full"></x-textarea>
|
||||
@error('env')
|
||||
<x-input-error class="mt-2" :messages="$message" />
|
||||
@enderror
|
||||
|
Loading…
x
Reference in New Issue
Block a user