mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-02 14:36:17 +00:00
deploy Wordpress sites via VitoDeploy (#83)
This commit is contained in:
@ -2,14 +2,12 @@
|
||||
|
||||
namespace App\SiteTypes;
|
||||
|
||||
use App\Enums\SiteStatus;
|
||||
use App\Events\Broadcast;
|
||||
use App\Enums\SiteFeature;
|
||||
use App\Jobs\Site\CloneRepository;
|
||||
use App\Jobs\Site\ComposerInstall;
|
||||
use App\Jobs\Site\CreateVHost;
|
||||
use App\Jobs\Site\DeployKey;
|
||||
use Illuminate\Support\Facades\Bus;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Throwable;
|
||||
|
||||
@ -20,12 +18,22 @@ public function language(): string
|
||||
return 'php';
|
||||
}
|
||||
|
||||
public function supportedFeatures(): array
|
||||
{
|
||||
return [
|
||||
SiteFeature::DEPLOYMENT,
|
||||
SiteFeature::ENV,
|
||||
SiteFeature::SSL,
|
||||
SiteFeature::QUEUES,
|
||||
];
|
||||
}
|
||||
|
||||
public function createValidationRules(array $input): array
|
||||
{
|
||||
return [
|
||||
'php_version' => [
|
||||
'required',
|
||||
'in:'.implode(',', $this->site->server->installedPHPVersions()),
|
||||
Rule::in($this->site->server->installedPHPVersions()),
|
||||
],
|
||||
'source_control' => [
|
||||
'required',
|
||||
@ -44,9 +52,9 @@ public function createFields(array $input): array
|
||||
{
|
||||
return [
|
||||
'web_directory' => $input['web_directory'] ?? '',
|
||||
'source_control_id' => $input['source_control'] ?? '',
|
||||
'repository' => $input['repository'] ?? '',
|
||||
'branch' => $input['branch'] ?? '',
|
||||
'source_control_id' => $input['source_control'],
|
||||
'repository' => $input['repository'],
|
||||
'branch' => $input['branch'],
|
||||
];
|
||||
}
|
||||
|
||||
@ -54,6 +62,7 @@ public function data(array $input): array
|
||||
{
|
||||
return [
|
||||
'composer' => (bool) $input['composer'],
|
||||
'php_version' => $input['php_version'],
|
||||
];
|
||||
}
|
||||
|
||||
@ -76,33 +85,12 @@ function () {
|
||||
}
|
||||
|
||||
$chain[] = function () {
|
||||
$this->site->update([
|
||||
'status' => SiteStatus::READY,
|
||||
'progress' => 100,
|
||||
]);
|
||||
event(
|
||||
new Broadcast('install-site-finished', [
|
||||
'site' => $this->site,
|
||||
])
|
||||
);
|
||||
/** @todo notify */
|
||||
$this->site->installationFinished();
|
||||
};
|
||||
|
||||
Bus::chain($chain)
|
||||
->catch(function (Throwable $e) {
|
||||
$this->site->update([
|
||||
'status' => SiteStatus::INSTALLATION_FAILED,
|
||||
]);
|
||||
event(
|
||||
new Broadcast('install-site-failed', [
|
||||
'site' => $this->site,
|
||||
])
|
||||
);
|
||||
/** @todo notify */
|
||||
Log::error('install-site-error', [
|
||||
'error' => (string) $e,
|
||||
]);
|
||||
throw $e;
|
||||
$this->site->installationFailed($e);
|
||||
})
|
||||
->onConnection('ssh-long')
|
||||
->dispatch();
|
||||
|
Reference in New Issue
Block a user