fix: shorter cuids (7)
feat: show deployments
This commit is contained in:
@@ -19,12 +19,10 @@ class DispatchRemoteProcess
|
||||
$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 @@ namespace App\Enums;
|
||||
enum ActivityTypes: string
|
||||
{
|
||||
case REMOTE_PROCESS = 'remote_process';
|
||||
case DEPLOYMENT = 'deployment';
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ class ProjectController extends Controller
|
||||
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 @@ class DeployApplication extends Component
|
||||
$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 @@ class DeployApplication extends Component
|
||||
$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 @@ class Application extends BaseModel
|
||||
{
|
||||
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 @@ abstract class BaseModel extends Model
|
||||
parent::boot();
|
||||
|
||||
static::creating(function (Model $model) {
|
||||
$model->uuid = (string) new Cuid2();
|
||||
$model->uuid = (string) new Cuid2(7);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ class User extends Authenticatable
|
||||
parent::boot();
|
||||
|
||||
static::creating(function (Model $model) {
|
||||
$model->uuid = (string) new Cuid2();
|
||||
$model->uuid = (string) new Cuid2(7);
|
||||
});
|
||||
}
|
||||
public function teams()
|
||||
|
||||
Reference in New Issue
Block a user