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()
|
||||
->withProperties($properties)
|
||||
->performedOn($remoteProcessArgs->model)
|
||||
->event('deployment')
|
||||
->log("");
|
||||
} else {
|
||||
$this->activity = activity()
|
||||
->withProperties($remoteProcessArgs->toArray())
|
||||
->event('remote_process')
|
||||
->log("");
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,8 @@ class RunRemoteProcess
|
||||
*/
|
||||
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.');
|
||||
}
|
||||
|
||||
|
@ -5,4 +5,5 @@
|
||||
enum ActivityTypes: string
|
||||
{
|
||||
case REMOTE_PROCESS = 'remote_process';
|
||||
case DEPLOYMENT = 'deployment';
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public function application()
|
||||
if (!$application) {
|
||||
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()
|
||||
{
|
||||
|
@ -36,7 +36,7 @@ public function deploy()
|
||||
$wildcard_domain = $project_wildcard_domain ?? $global_wildcard_domain ?? null;
|
||||
|
||||
// Create Deployment ID
|
||||
$this->deployment_uuid = new Cuid2(12);
|
||||
$this->deployment_uuid = new Cuid2(7);
|
||||
$workdir = "/artifacts/{$this->deployment_uuid}";
|
||||
|
||||
// Start build process
|
||||
@ -48,20 +48,9 @@ public function deploy()
|
||||
$this->command[] = "docker stop -t 0 {$this->deployment_uuid} >/dev/null";
|
||||
$this->activity = remoteProcess($this->command, $destination->server, $this->deployment_uuid, $application);
|
||||
|
||||
// Create Deployment
|
||||
Deployment::create([
|
||||
'uuid' => $this->deployment_uuid,
|
||||
'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
|
||||
]);
|
||||
$currentUrl = url()->previous();
|
||||
$deploymentUrl = "$currentUrl/deployment/$this->deployment_uuid";
|
||||
return redirect($deploymentUrl);
|
||||
}
|
||||
public function render()
|
||||
{
|
||||
|
@ -22,7 +22,10 @@ public function source()
|
||||
{
|
||||
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)
|
||||
{
|
||||
return Activity::where('subject_id', $this->id)->where('properties->deployment_uuid', '=', $deployment_uuid)->first();
|
||||
|
@ -12,7 +12,7 @@ protected static function boot()
|
||||
parent::boot();
|
||||
|
||||
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();
|
||||
|
||||
static::creating(function (Model $model) {
|
||||
$model->uuid = (string) new Cuid2();
|
||||
$model->uuid = (string) new Cuid2(7);
|
||||
});
|
||||
}
|
||||
public function teams()
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
use App\Actions\RemoteProcess\DispatchRemoteProcess;
|
||||
use App\Data\RemoteProcessArgs;
|
||||
use App\Enums\ActivityTypes;
|
||||
use App\Models\Server;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
@ -29,6 +30,7 @@ function remoteProcess(
|
||||
|
||||
return resolve(DispatchRemoteProcess::class, [
|
||||
'remoteProcessArgs' => new RemoteProcessArgs(
|
||||
type: $deployment_uuid ? ActivityTypes::DEPLOYMENT->value : ActivityTypes::REMOTE_PROCESS->value,
|
||||
model: $model,
|
||||
server_ip: $server->ip,
|
||||
deployment_uuid: $deployment_uuid,
|
||||
|
@ -3,4 +3,13 @@
|
||||
<p>Name: {{ $project->name }}</p>
|
||||
<p>UUID: {{ $project->uuid }}</p>
|
||||
<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>
|
||||
|
@ -20,9 +20,12 @@
|
||||
Route::middleware(['auth'])->group(function () {
|
||||
Route::get('/', [HomeController::class, 'show'])->name('home');
|
||||
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}/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}/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');
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user