From 3f1b7192ff7e7d45836b55218d1d4390077fa251 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 15 May 2024 11:31:03 +0200 Subject: [PATCH] feat: save commit message and better view on deployments --- app/Models/ApplicationDeploymentQueue.php | 11 ++++++-- ...commit_message_to_app_deployment_queue.php | 28 +++++++++++++++++++ .../application/deployment/index.blade.php | 7 ++++- 3 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 database/migrations/2024_05_15_091757_add_commit_message_to_app_deployment_queue.php diff --git a/app/Models/ApplicationDeploymentQueue.php b/app/Models/ApplicationDeploymentQueue.php index 7f3f36d0a..a55d3a4a2 100644 --- a/app/Models/ApplicationDeploymentQueue.php +++ b/app/Models/ApplicationDeploymentQueue.php @@ -9,7 +9,8 @@ class ApplicationDeploymentQueue extends Model { protected $guarded = []; - public function setStatus(string $status) { + public function setStatus(string $status) + { $this->update([ 'status' => $status, ]); @@ -21,7 +22,13 @@ class ApplicationDeploymentQueue extends Model } return collect(json_decode($this->logs))->where('name', $name)->first()?->output ?? null; } - + public function commitMessage() + { + if (empty($this->commit_message) || is_null($this->commit_message)) { + return null; + } + return str($this->commit_message)->trim()->limit(300)->value(); + } public function addLogEntry(string $message, string $type = 'stdout', bool $hidden = false) { if ($type === 'error') { diff --git a/database/migrations/2024_05_15_091757_add_commit_message_to_app_deployment_queue.php b/database/migrations/2024_05_15_091757_add_commit_message_to_app_deployment_queue.php new file mode 100644 index 000000000..0128e2be5 --- /dev/null +++ b/database/migrations/2024_05_15_091757_add_commit_message_to_app_deployment_queue.php @@ -0,0 +1,28 @@ +string('commit_message', 300)->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('application_deployment_queues', function (Blueprint $table) { + $table->dropColumn('commit_message'); + }); + } +}; diff --git a/resources/views/livewire/project/application/deployment/index.blade.php b/resources/views/livewire/project/application/deployment/index.blade.php index d914eee17..ea7262a27 100644 --- a/resources/views/livewire/project/application/deployment/index.blade.php +++ b/resources/views/livewire/project/application/deployment/index.blade.php @@ -71,7 +71,12 @@
- (SHA {{ data_get($deployment, 'commit') }})
+ @if ($deployment->commitMessage()) + ({{data_get_str($deployment, 'commit')->limit(7)}} - {{ $deployment->commitMessage() }}) + @else + {{ data_get_str($deployment, 'commit')->limit(7) }} + @endif +
@endif