feat: add commit author to all deployment notifications

This commit is contained in:
Selim Emre Toy 2026-02-21 12:57:07 +01:00
parent fd24a54304
commit f200b434fd
6 changed files with 90 additions and 0 deletions

View file

@ -35,6 +35,7 @@ use OpenApi\Attributes as OA;
'only_this_server' => ['type' => 'boolean'],
'rollback' => ['type' => 'boolean'],
'commit_message' => ['type' => 'string'],
'commit_author' => ['type' => 'string'],
],
)]
class ApplicationDeploymentQueue extends Model

View file

@ -3,6 +3,7 @@
namespace App\Notifications\Application;
use App\Models\Application;
use App\Models\ApplicationDeploymentQueue;
use App\Models\ApplicationPreview;
use App\Notifications\CustomEmailNotification;
use App\Notifications\Dto\DiscordMessage;
@ -63,11 +64,14 @@ class DeploymentFailed extends CustomEmailNotification
$fqdn = $this->preview->fqdn;
$mail->subject('Coolify: Deployment failed of pull request #'.$this->preview->pull_request_id.' of '.$this->application_name.'.');
}
$deployment = ApplicationDeploymentQueue::where('deployment_uuid', $this->deployment_uuid)->first();
$mail->view('emails.application-deployment-failed', [
'name' => $this->application_name,
'fqdn' => $fqdn,
'deployment_url' => $this->deployment_url,
'pull_request_id' => data_get($this->preview, 'pull_request_id', 0),
'commit_author' => $deployment?->commit_author,
]);
return $mail;
@ -111,6 +115,11 @@ class DeploymentFailed extends CustomEmailNotification
$message->addField('Deployment Logs', '[Link]('.$this->deployment_url.')');
}
$deployment = ApplicationDeploymentQueue::where('deployment_uuid', $this->deployment_uuid)->first();
if ($deployment && $deployment->commit_author) {
$message->addField('Commit Author', $deployment->commit_author, true);
}
return $message;
}
@ -121,6 +130,12 @@ class DeploymentFailed extends CustomEmailNotification
} else {
$message = 'Coolify: Deployment failed of '.$this->application_name.' ('.$this->fqdn.'): ';
}
$deployment = ApplicationDeploymentQueue::where('deployment_uuid', $this->deployment_uuid)->first();
if ($deployment && $deployment->commit_author) {
$message .= "\nCommit Author: {$deployment->commit_author}";
}
$buttons[] = [
'text' => 'Deployment logs',
'url' => $this->deployment_url,
@ -144,6 +159,11 @@ class DeploymentFailed extends CustomEmailNotification
$message = "Deployment failed for {$this->application_name}";
}
$deployment = ApplicationDeploymentQueue::where('deployment_uuid', $this->deployment_uuid)->first();
if ($deployment && $deployment->commit_author) {
$message .= "\nCommit Author: {$deployment->commit_author}";
}
$buttons[] = [
'text' => 'Deployment logs',
'url' => $this->deployment_url,
@ -175,6 +195,11 @@ class DeploymentFailed extends CustomEmailNotification
}
}
$deployment = ApplicationDeploymentQueue::where('deployment_uuid', $this->deployment_uuid)->first();
if ($deployment && $deployment->commit_author) {
$description .= "\n*Commit Author:* {$deployment->commit_author}";
}
$description .= "\n\n*Project:* ".data_get($this->application, 'environment.project.name');
$description .= "\n*Environment:* {$this->environment_name}";
$description .= "\n*<{$this->deployment_url}|Deployment Logs>*";
@ -209,6 +234,11 @@ class DeploymentFailed extends CustomEmailNotification
$data['fqdn'] = $this->fqdn;
}
$deployment = ApplicationDeploymentQueue::where('deployment_uuid', $this->deployment_uuid)->first();
if ($deployment && $deployment->commit_author) {
$data['commit_author'] = $deployment->commit_author;
}
return $data;
}
}

View file

@ -3,6 +3,7 @@
namespace App\Notifications\Application;
use App\Models\Application;
use App\Models\ApplicationDeploymentQueue;
use App\Models\ApplicationPreview;
use App\Notifications\CustomEmailNotification;
use App\Notifications\Dto\DiscordMessage;
@ -63,11 +64,14 @@ class DeploymentSuccess extends CustomEmailNotification
$fqdn = $this->preview->fqdn;
$mail->subject("Coolify: Pull request #{$pull_request_id} of {$this->application_name} deployed successfully");
}
$deployment = ApplicationDeploymentQueue::where('deployment_uuid', $this->deployment_uuid)->first();
$mail->view('emails.application-deployment-success', [
'name' => $this->application_name,
'fqdn' => $fqdn,
'deployment_url' => $this->deployment_url,
'pull_request_id' => $pull_request_id,
'commit_author' => $deployment?->commit_author,
]);
return $mail;
@ -108,6 +112,11 @@ class DeploymentSuccess extends CustomEmailNotification
$message->addField('Deployment logs', '[Link]('.$this->deployment_url.')');
}
$deployment = ApplicationDeploymentQueue::where('deployment_uuid', $this->deployment_uuid)->first();
if ($deployment && $deployment->commit_author) {
$message->addField('Commit Author', $deployment->commit_author, true);
}
return $message;
}
@ -130,6 +139,12 @@ class DeploymentSuccess extends CustomEmailNotification
];
}
}
$deployment = ApplicationDeploymentQueue::where('deployment_uuid', $this->deployment_uuid)->first();
if ($deployment && $deployment->commit_author) {
$message .= "\nCommit Author: {$deployment->commit_author}";
}
$buttons[] = [
'text' => 'Deployment logs',
'url' => $this->deployment_url,
@ -164,6 +179,12 @@ class DeploymentSuccess extends CustomEmailNotification
];
}
}
$deployment = ApplicationDeploymentQueue::where('deployment_uuid', $this->deployment_uuid)->first();
if ($deployment && $deployment->commit_author) {
$message .= "\nCommit Author: {$deployment->commit_author}";
}
$buttons[] = [
'text' => 'Deployment logs',
'url' => $this->deployment_url,
@ -194,6 +215,10 @@ class DeploymentSuccess extends CustomEmailNotification
$description .= "\nApplication URL: {$this->fqdn}";
}
}
$deployment = ApplicationDeploymentQueue::where('deployment_uuid', $this->deployment_uuid)->first();
if ($deployment && $deployment->commit_author) {
$description .= "\n*Commit Author:* {$deployment->commit_author}";
}
$description .= "\n\n*Project:* ".data_get($this->application, 'environment.project.name');
$description .= "\n*Environment:* {$this->environment_name}";
@ -229,6 +254,11 @@ class DeploymentSuccess extends CustomEmailNotification
$data['fqdn'] = $this->fqdn;
}
$deployment = ApplicationDeploymentQueue::where('deployment_uuid', $this->deployment_uuid)->first();
if ($deployment && $deployment->commit_author) {
$data['commit_author'] = $deployment->commit_author;
}
return $data;
}
}

View file

@ -0,0 +1,21 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void
{
Schema::table('application_deployment_queues', function (Blueprint $table) {
$table->string('commit_author')->nullable()->after('commit_message');
});
}
public function down(): void
{
Schema::table('application_deployment_queues', function (Blueprint $table) {
$table->dropColumn('commit_author');
});
}
};

View file

@ -6,5 +6,9 @@ Failed to deploy a pull request #{{ $pull_request_id }} of {{ $name }} at
[{{ $fqdn }}]({{ $fqdn }}).
@endif
@if (isset($commit_author))
Commit Author: {{ $commit_author }}
@endif
[View Deployment Logs]({{ $deployment_url }})
</x-emails.layout>

View file

@ -6,6 +6,10 @@ Pull request #{{ $pull_request_id }} of {{ $name }} deployed successfully
[{{ $fqdn }}]({{ $fqdn }}).
@endif
@if (isset($commit_author))
Commit Author: {{ $commit_author }}
@endif
[View Deployment Logs]({{ $deployment_url }})
</x-emails.layout>