fixes
This commit is contained in:
parent
25870dadd8
commit
8991de2610
@ -9,6 +9,7 @@ class Deployments extends Component
|
|||||||
{
|
{
|
||||||
public int $application_id;
|
public int $application_id;
|
||||||
public $deployments = [];
|
public $deployments = [];
|
||||||
|
public int $deployments_count = 0;
|
||||||
public string $current_url;
|
public string $current_url;
|
||||||
public int $skip = 0;
|
public int $skip = 0;
|
||||||
public int $default_take = 8;
|
public int $default_take = 8;
|
||||||
@ -24,15 +25,14 @@ class Deployments extends Component
|
|||||||
}
|
}
|
||||||
public function load_deployments(int|null $take = null)
|
public function load_deployments(int|null $take = null)
|
||||||
{
|
{
|
||||||
ray('Take' . $take);
|
|
||||||
if ($take) {
|
if ($take) {
|
||||||
ray('Take is not null');
|
|
||||||
$this->skip = $this->skip + $take;
|
$this->skip = $this->skip + $take;
|
||||||
}
|
}
|
||||||
|
|
||||||
$take = $this->default_take;
|
$take = $this->default_take;
|
||||||
$this->deployments = Application::find($this->application_id)->deployments($this->skip, $take);
|
['deployments' => $deployments, 'count' => $count] = Application::find($this->application_id)->deployments($this->skip, $take);
|
||||||
|
$this->deployments = $deployments;
|
||||||
|
$this->deployments_count = $count;
|
||||||
if (count($this->deployments) !== 0 && count($this->deployments) < $take) {
|
if (count($this->deployments) !== 0 && count($this->deployments) < $take) {
|
||||||
$this->show_next = false;
|
$this->show_next = false;
|
||||||
return;
|
return;
|
||||||
|
@ -37,7 +37,6 @@ class Form extends Component
|
|||||||
{
|
{
|
||||||
$this->validate();
|
$this->validate();
|
||||||
$this->application->preview_url_template = str_replace(' ', '', $this->application->preview_url_template);
|
$this->application->preview_url_template = str_replace(' ', '', $this->application->preview_url_template);
|
||||||
ray($this->application->preview_url_template);
|
|
||||||
$this->application->save();
|
$this->application->save();
|
||||||
$this->generate_real_url();
|
$this->generate_real_url();
|
||||||
}
|
}
|
||||||
|
@ -41,12 +41,12 @@ class Previews extends Component
|
|||||||
$this->rate_limit_remaining = $rate_limit_remaining;
|
$this->rate_limit_remaining = $rate_limit_remaining;
|
||||||
$this->pull_requests = $data->sortBy('number')->values();
|
$this->pull_requests = $data->sortBy('number')->values();
|
||||||
}
|
}
|
||||||
public function deploy(int $pull_request_id, string|null $pull_request_html_url)
|
public function deploy(int $pull_request_id, string|null $pull_request_html_url = null)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$this->set_deployment_uuid();
|
$this->set_deployment_uuid();
|
||||||
$found = ApplicationPreview::where('application_id', $this->application->id)->where('pull_request_id', $pull_request_id)->first();
|
$found = ApplicationPreview::where('application_id', $this->application->id)->where('pull_request_id', $pull_request_id)->first();
|
||||||
if (!$found) {
|
if (!$found && !is_null($pull_request_html_url)) {
|
||||||
ApplicationPreview::create([
|
ApplicationPreview::create([
|
||||||
'application_id' => $this->application->id,
|
'application_id' => $this->application->id,
|
||||||
'pull_request_id' => $pull_request_id,
|
'pull_request_id' => $pull_request_id,
|
||||||
|
@ -269,7 +269,6 @@ COPY --from=$this->build_image_name /app/{$this->application->publish_directory}
|
|||||||
|
|
||||||
private function next(string $status)
|
private function next(string $status)
|
||||||
{
|
{
|
||||||
ray($this->application_deployment_queue->status, Str::of($this->application_deployment_queue->status)->startsWith('cancelled'));
|
|
||||||
if (!Str::of($this->application_deployment_queue->status)->startsWith('cancelled')) {
|
if (!Str::of($this->application_deployment_queue->status)->startsWith('cancelled')) {
|
||||||
$this->application_deployment_queue->update([
|
$this->application_deployment_queue->update([
|
||||||
'status' => $status,
|
'status' => $status,
|
||||||
@ -522,7 +521,7 @@ COPY --from=$this->build_image_name /app/{$this->application->publish_directory}
|
|||||||
} else {
|
} else {
|
||||||
$commandText = collect($command)->implode("\n");
|
$commandText = collect($command)->implode("\n");
|
||||||
}
|
}
|
||||||
ray('Executing command', $commandText);
|
ray('Executing command: ' . $commandText);
|
||||||
$this->activity->properties = $this->activity->properties->merge([
|
$this->activity->properties = $this->activity->properties->merge([
|
||||||
'command' => $commandText,
|
'command' => $commandText,
|
||||||
]);
|
]);
|
||||||
@ -623,7 +622,6 @@ COPY --from=$this->build_image_name /app/{$this->application->publish_directory}
|
|||||||
$nixpacks_command .= " --install-cmd \"{$this->application->install_command}\"";
|
$nixpacks_command .= " --install-cmd \"{$this->application->install_command}\"";
|
||||||
}
|
}
|
||||||
$nixpacks_command .= " {$this->workdir}";
|
$nixpacks_command .= " {$this->workdir}";
|
||||||
ray('Build command: ' . $nixpacks_command);
|
|
||||||
return $this->execute_in_builder($nixpacks_command);
|
return $this->execute_in_builder($nixpacks_command);
|
||||||
}
|
}
|
||||||
private function stop_running_container()
|
private function stop_running_container()
|
||||||
|
@ -34,9 +34,8 @@ class ContainerStatusJob implements ShouldQueue, ShouldBeUnique
|
|||||||
public function handle(): void
|
public function handle(): void
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
ray('running ContainerStatusJob', $this->container_name, $this->pull_request_id);
|
|
||||||
$status = get_container_status(server: $this->application->destination->server, container_id: $this->container_name, throwError: false);
|
$status = get_container_status(server: $this->application->destination->server, container_id: $this->container_name, throwError: false);
|
||||||
ray('ContainerStatusJob', $status);
|
ray('Container ' . $this->container_name . ' statuus is ' . $status);
|
||||||
if ($this->pull_request_id) {
|
if ($this->pull_request_id) {
|
||||||
$preview = ApplicationPreview::findPreviewByApplicationAndPullId($this->application->id, $this->pull_request_id);
|
$preview = ApplicationPreview::findPreviewByApplicationAndPullId($this->application->id, $this->pull_request_id);
|
||||||
$preview->status = $status;
|
$preview->status = $status;
|
||||||
|
@ -146,8 +146,13 @@ class Application extends BaseModel
|
|||||||
|
|
||||||
public function deployments(int $skip = 0, int $take = 10)
|
public function deployments(int $skip = 0, int $take = 10)
|
||||||
{
|
{
|
||||||
ray('Skip ' . $skip . ' Take ' . $take);
|
$deployments = ApplicationDeploymentQueue::where('application_id', $this->id)->orderBy('created_at', 'desc');
|
||||||
return ApplicationDeploymentQueue::where('application_id', $this->id)->orderBy('created_at', 'desc')->skip($skip)->take($take)->get();
|
$count = $deployments->count();
|
||||||
|
$deployments = $deployments->skip($skip)->take($take)->get();
|
||||||
|
return [
|
||||||
|
'count' => $count,
|
||||||
|
'deployments' => $deployments
|
||||||
|
];
|
||||||
}
|
}
|
||||||
public function get_deployment(string $deployment_uuid)
|
public function get_deployment(string $deployment_uuid)
|
||||||
{
|
{
|
||||||
|
@ -16,7 +16,7 @@ function queue_application_deployment(int $application_id, string $deployment_uu
|
|||||||
]);
|
]);
|
||||||
$queued_deployments = ApplicationDeploymentQueue::where('application_id', $application_id)->where('status', 'queued')->get()->sortByDesc('created_at');
|
$queued_deployments = ApplicationDeploymentQueue::where('application_id', $application_id)->where('status', 'queued')->get()->sortByDesc('created_at');
|
||||||
$running_deployments = ApplicationDeploymentQueue::where('application_id', $application_id)->where('status', 'in_progress')->get()->sortByDesc('created_at');
|
$running_deployments = ApplicationDeploymentQueue::where('application_id', $application_id)->where('status', 'in_progress')->get()->sortByDesc('created_at');
|
||||||
ray('Q:' . $queued_deployments->count() . 'R:' . $running_deployments->count() . '|Queuing deployment: ' . $deployment_uuid . ' of applicationID: ' . $application_id . ' pull request: ' . $pull_request_id . ' with commit: ' . $commit . ' and is it forced: ' . $force_rebuild);
|
ray('Q:' . $queued_deployments->count() . 'R:' . $running_deployments->count() . '| Queuing deployment: ' . $deployment_uuid . ' of applicationID: ' . $application_id . ' pull request: ' . $pull_request_id . ' with commit: ' . $commit . ' and is it forced: ' . $force_rebuild);
|
||||||
if ($queued_deployments->count() > 1) {
|
if ($queued_deployments->count() > 1) {
|
||||||
$queued_deployments = $queued_deployments->skip(1);
|
$queued_deployments = $queued_deployments->skip(1);
|
||||||
$queued_deployments->each(function ($queued_deployment, $key) {
|
$queued_deployments->each(function ($queued_deployment, $key) {
|
||||||
|
@ -3,13 +3,13 @@
|
|||||||
<div>
|
<div>
|
||||||
<h3>Actions</h3>
|
<h3>Actions</h3>
|
||||||
@if ($show_next)
|
@if ($show_next)
|
||||||
<x-forms.button isHighlighted wire:click="load_deployments({{ $default_take }})">Load More
|
<x-forms.button isHighlighted wire:click="load_deployments({{ $default_take }})">Load Previous
|
||||||
Deployments</x-forms.button>
|
Deployments</x-forms.button>
|
||||||
@else
|
@else
|
||||||
<x-forms.button disabled>No More Deployments</x-forms.button>
|
<x-forms.button disabled>No More Deployments</x-forms.button>
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
<h3>Deployments</h3>
|
<h3>Deployments <span class="text-xs">({{ $deployments_count }})</span></h3>
|
||||||
@foreach ($deployments as $deployment)
|
@foreach ($deployments as $deployment)
|
||||||
<a @class([
|
<a @class([
|
||||||
'bg-coolgray-200 p-2 border-l border-dashed transition-colors hover:no-underline',
|
'bg-coolgray-200 p-2 border-l border-dashed transition-colors hover:no-underline',
|
||||||
@ -28,7 +28,8 @@
|
|||||||
class="hover:no-underline">
|
class="hover:no-underline">
|
||||||
<div class="flex flex-col justify-start">
|
<div class="flex flex-col justify-start">
|
||||||
<div>
|
<div>
|
||||||
{{ $deployment->deployment_uuid }} <span class="text-sm text-warning">></span>
|
{{ $deployment->id }} <span class="text-sm text-warning">></span> {{ $deployment->deployment_uuid }} <span
|
||||||
|
class="text-sm text-warning">></span>
|
||||||
{{ $deployment->status }}
|
{{ $deployment->status }}
|
||||||
</div>
|
</div>
|
||||||
@if (data_get($deployment, 'pull_request_id'))
|
@if (data_get($deployment, 'pull_request_id'))
|
||||||
@ -47,7 +48,6 @@
|
|||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
<div class="flex flex-col" x-data="elapsedTime('{{ $deployment->deployment_uuid }}', '{{ $deployment->status }}', '{{ $deployment->created_at }}', '{{ $deployment->updated_at }}')">
|
<div class="flex flex-col" x-data="elapsedTime('{{ $deployment->deployment_uuid }}', '{{ $deployment->status }}', '{{ $deployment->created_at }}', '{{ $deployment->updated_at }}')">
|
||||||
<div>Finished <span x-text="measure_since_started()">0s</span> in <span class="font-bold"
|
<div>Finished <span x-text="measure_since_started()">0s</span> in <span class="font-bold"
|
||||||
x-text="measure_finished_time()">0s</span></div>
|
x-text="measure_finished_time()">0s</span></div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user