fix: shorter cuids (7)
feat: show deployments
This commit is contained in:
parent
78c4344583
commit
1c259fe12e
@ -19,12 +19,10 @@ public function __construct(RemoteProcessArgs $remoteProcessArgs)
|
|||||||
$this->activity = activity()
|
$this->activity = activity()
|
||||||
->withProperties($properties)
|
->withProperties($properties)
|
||||||
->performedOn($remoteProcessArgs->model)
|
->performedOn($remoteProcessArgs->model)
|
||||||
->event('deployment')
|
|
||||||
->log("");
|
->log("");
|
||||||
} else {
|
} else {
|
||||||
$this->activity = activity()
|
$this->activity = activity()
|
||||||
->withProperties($remoteProcessArgs->toArray())
|
->withProperties($remoteProcessArgs->toArray())
|
||||||
->event('remote_process')
|
|
||||||
->log("");
|
->log("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,8 @@ class RunRemoteProcess
|
|||||||
*/
|
*/
|
||||||
public function __construct(Activity $activity)
|
public function __construct(Activity $activity)
|
||||||
{
|
{
|
||||||
if ($activity->getExtraProperty('type') !== ActivityTypes::REMOTE_PROCESS->value) {
|
|
||||||
|
if ($activity->getExtraProperty('type') !== ActivityTypes::REMOTE_PROCESS->value && $activity->getExtraProperty('type') !== ActivityTypes::DEPLOYMENT->value) {
|
||||||
throw new \RuntimeException('Incompatible Activity to run a remote command.');
|
throw new \RuntimeException('Incompatible Activity to run a remote command.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,4 +5,5 @@
|
|||||||
enum ActivityTypes: string
|
enum ActivityTypes: string
|
||||||
{
|
{
|
||||||
case REMOTE_PROCESS = 'remote_process';
|
case REMOTE_PROCESS = 'remote_process';
|
||||||
|
case DEPLOYMENT = 'deployment';
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ public function application()
|
|||||||
if (!$application) {
|
if (!$application) {
|
||||||
return redirect()->route('home');
|
return redirect()->route('home');
|
||||||
}
|
}
|
||||||
return view('project.application', ['project' => $project, 'application' => $application]);
|
return view('project.application', ['project' => $project, 'application' => $application, 'deployments' => $application->deployments()]);
|
||||||
}
|
}
|
||||||
public function database()
|
public function database()
|
||||||
{
|
{
|
||||||
|
@ -36,7 +36,7 @@ public function deploy()
|
|||||||
$wildcard_domain = $project_wildcard_domain ?? $global_wildcard_domain ?? null;
|
$wildcard_domain = $project_wildcard_domain ?? $global_wildcard_domain ?? null;
|
||||||
|
|
||||||
// Create Deployment ID
|
// Create Deployment ID
|
||||||
$this->deployment_uuid = new Cuid2(12);
|
$this->deployment_uuid = new Cuid2(7);
|
||||||
$workdir = "/artifacts/{$this->deployment_uuid}";
|
$workdir = "/artifacts/{$this->deployment_uuid}";
|
||||||
|
|
||||||
// Start build process
|
// Start build process
|
||||||
@ -48,20 +48,9 @@ public function deploy()
|
|||||||
$this->command[] = "docker stop -t 0 {$this->deployment_uuid} >/dev/null";
|
$this->command[] = "docker stop -t 0 {$this->deployment_uuid} >/dev/null";
|
||||||
$this->activity = remoteProcess($this->command, $destination->server, $this->deployment_uuid, $application);
|
$this->activity = remoteProcess($this->command, $destination->server, $this->deployment_uuid, $application);
|
||||||
|
|
||||||
// Create Deployment
|
$currentUrl = url()->previous();
|
||||||
Deployment::create([
|
$deploymentUrl = "$currentUrl/deployment/$this->deployment_uuid";
|
||||||
'uuid' => $this->deployment_uuid,
|
return redirect($deploymentUrl);
|
||||||
'type_id' => $application->id,
|
|
||||||
'type_type' => Application::class,
|
|
||||||
'activity_log_id' => $this->activity->id,
|
|
||||||
]);
|
|
||||||
// Redirect to deployment page
|
|
||||||
return redirect()->route('project.deployment', [
|
|
||||||
"deployment_uuid" => $this->deployment_uuid,
|
|
||||||
"project_uuid" => $application->environment->project->uuid,
|
|
||||||
"environment_name" => $application->environment->name,
|
|
||||||
"application_uuid" => $application->uuid
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
|
@ -22,7 +22,10 @@ public function source()
|
|||||||
{
|
{
|
||||||
return $this->morphTo();
|
return $this->morphTo();
|
||||||
}
|
}
|
||||||
|
public function deployments()
|
||||||
|
{
|
||||||
|
return Activity::where('subject_id', $this->id)->where('properties->deployment_uuid', '!=', null)->orderBy('created_at', 'desc')->get();
|
||||||
|
}
|
||||||
public function get_deployment(string $deployment_uuid)
|
public function get_deployment(string $deployment_uuid)
|
||||||
{
|
{
|
||||||
return Activity::where('subject_id', $this->id)->where('properties->deployment_uuid', '=', $deployment_uuid)->first();
|
return Activity::where('subject_id', $this->id)->where('properties->deployment_uuid', '=', $deployment_uuid)->first();
|
||||||
|
@ -12,7 +12,7 @@ protected static function boot()
|
|||||||
parent::boot();
|
parent::boot();
|
||||||
|
|
||||||
static::creating(function (Model $model) {
|
static::creating(function (Model $model) {
|
||||||
$model->uuid = (string) new Cuid2();
|
$model->uuid = (string) new Cuid2(7);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ protected static function boot()
|
|||||||
parent::boot();
|
parent::boot();
|
||||||
|
|
||||||
static::creating(function (Model $model) {
|
static::creating(function (Model $model) {
|
||||||
$model->uuid = (string) new Cuid2();
|
$model->uuid = (string) new Cuid2(7);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
public function teams()
|
public function teams()
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
use App\Actions\RemoteProcess\DispatchRemoteProcess;
|
use App\Actions\RemoteProcess\DispatchRemoteProcess;
|
||||||
use App\Data\RemoteProcessArgs;
|
use App\Data\RemoteProcessArgs;
|
||||||
|
use App\Enums\ActivityTypes;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
@ -29,6 +30,7 @@ function remoteProcess(
|
|||||||
|
|
||||||
return resolve(DispatchRemoteProcess::class, [
|
return resolve(DispatchRemoteProcess::class, [
|
||||||
'remoteProcessArgs' => new RemoteProcessArgs(
|
'remoteProcessArgs' => new RemoteProcessArgs(
|
||||||
|
type: $deployment_uuid ? ActivityTypes::DEPLOYMENT->value : ActivityTypes::REMOTE_PROCESS->value,
|
||||||
model: $model,
|
model: $model,
|
||||||
server_ip: $server->ip,
|
server_ip: $server->ip,
|
||||||
deployment_uuid: $deployment_uuid,
|
deployment_uuid: $deployment_uuid,
|
||||||
|
@ -3,4 +3,13 @@
|
|||||||
<p>Name: {{ $project->name }}</p>
|
<p>Name: {{ $project->name }}</p>
|
||||||
<p>UUID: {{ $project->uuid }}</p>
|
<p>UUID: {{ $project->uuid }}</p>
|
||||||
<livewire:deploy-application :application_uuid="$application->uuid" />
|
<livewire:deploy-application :application_uuid="$application->uuid" />
|
||||||
|
<div>
|
||||||
|
<h1>Deployments</h1>
|
||||||
|
@foreach ($deployments as $deployment)
|
||||||
|
<p>
|
||||||
|
<a href="{{ url()->current() }}/deployment/{{ data_get($deployment->properties, 'deployment_uuid') }}">
|
||||||
|
{{ data_get($deployment->properties, 'deployment_uuid') }}</a>
|
||||||
|
</p>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
</x-layout>
|
</x-layout>
|
||||||
|
@ -20,9 +20,12 @@
|
|||||||
Route::middleware(['auth'])->group(function () {
|
Route::middleware(['auth'])->group(function () {
|
||||||
Route::get('/', [HomeController::class, 'show'])->name('home');
|
Route::get('/', [HomeController::class, 'show'])->name('home');
|
||||||
Route::get('/project/{project_uuid}', [ProjectController::class, 'environments'])->name('project.environments');
|
Route::get('/project/{project_uuid}', [ProjectController::class, 'environments'])->name('project.environments');
|
||||||
|
|
||||||
Route::get('/project/{project_uuid}/{environment_name}', [ProjectController::class, 'resources'])->name('project.resources');
|
Route::get('/project/{project_uuid}/{environment_name}', [ProjectController::class, 'resources'])->name('project.resources');
|
||||||
|
|
||||||
Route::get('/project/{project_uuid}/{environment_name}/application/{application_uuid}', [ProjectController::class, 'application'])->name('project.application');
|
Route::get('/project/{project_uuid}/{environment_name}/application/{application_uuid}', [ProjectController::class, 'application'])->name('project.application');
|
||||||
Route::get('/project/{project_uuid}/{environment_name}/application/{application_uuid}/deployment/{deployment_uuid}', [ProjectController::class, 'deployment'])->name('project.deployment');
|
Route::get('/project/{project_uuid}/{environment_name}/application/{application_uuid}/deployment/{deployment_uuid}', [ProjectController::class, 'deployment'])->name('project.deployment');
|
||||||
|
|
||||||
Route::get('/project/{project_uuid}/{environment_name}/database/{database_uuid}', [ProjectController::class, 'database'])->name('project.database');
|
Route::get('/project/{project_uuid}/{environment_name}/database/{database_uuid}', [ProjectController::class, 'database'])->name('project.database');
|
||||||
Route::get('/project/{project_uuid}/{environment_name}/service/{service_uuid}', [ProjectController::class, 'service'])->name('project.service');
|
Route::get('/project/{project_uuid}/{environment_name}/service/{service_uuid}', [ProjectController::class, 'service'])->name('project.service');
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user