feat: save commit message and better view on deployments

This commit is contained in:
Andras Bacsai 2024-05-15 11:31:03 +02:00
parent b992b19c66
commit 3f1b7192ff
3 changed files with 43 additions and 3 deletions

View File

@ -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 @@ public function getOutput($name)
}
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') {

View File

@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('application_deployment_queues', function (Blueprint $table) {
$table->string('commit_message', 300)->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('application_deployment_queues', function (Blueprint $table) {
$table->dropColumn('commit_message');
});
}
};

View File

@ -71,7 +71,12 @@ class="w-6 h-6" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<div class="dark:hover:text-white"
x-on:click.stop="goto('{{ $application->gitCommitLink(data_get($deployment, 'commit')) }}')">
<div class="text-xs underline">
(SHA {{ data_get($deployment, 'commit') }})</div>
@if ($deployment->commitMessage())
({{data_get_str($deployment, 'commit')->limit(7)}} - {{ $deployment->commitMessage() }})
@else
{{ data_get_str($deployment, 'commit')->limit(7) }}
@endif
</div>
</div>
@endif
</div>