diff --git a/app/Models/ApplicationDeploymentQueue.php b/app/Models/ApplicationDeploymentQueue.php index 34257e7a7..503d51472 100644 --- a/app/Models/ApplicationDeploymentQueue.php +++ b/app/Models/ApplicationDeploymentQueue.php @@ -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 diff --git a/app/Notifications/Application/DeploymentFailed.php b/app/Notifications/Application/DeploymentFailed.php index 8fff7f03b..90b5d27d7 100644 --- a/app/Notifications/Application/DeploymentFailed.php +++ b/app/Notifications/Application/DeploymentFailed.php @@ -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; } } diff --git a/app/Notifications/Application/DeploymentSuccess.php b/app/Notifications/Application/DeploymentSuccess.php index 415df5831..b35651885 100644 --- a/app/Notifications/Application/DeploymentSuccess.php +++ b/app/Notifications/Application/DeploymentSuccess.php @@ -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; } } diff --git a/database/migrations/2025_02_20_165000_add_commit_author_to_application_deployment_queues.php b/database/migrations/2025_02_20_165000_add_commit_author_to_application_deployment_queues.php new file mode 100644 index 000000000..7ca1ee755 --- /dev/null +++ b/database/migrations/2025_02_20_165000_add_commit_author_to_application_deployment_queues.php @@ -0,0 +1,21 @@ +string('commit_author')->nullable()->after('commit_message'); + }); + } + + public function down(): void + { + Schema::table('application_deployment_queues', function (Blueprint $table) { + $table->dropColumn('commit_author'); + }); + } +}; diff --git a/resources/views/emails/application-deployment-failed.blade.php b/resources/views/emails/application-deployment-failed.blade.php index a97c650b2..c49401885 100644 --- a/resources/views/emails/application-deployment-failed.blade.php +++ b/resources/views/emails/application-deployment-failed.blade.php @@ -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 }}) diff --git a/resources/views/emails/application-deployment-success.blade.php b/resources/views/emails/application-deployment-success.blade.php index bc09a2479..82c61a7ee 100644 --- a/resources/views/emails/application-deployment-success.blade.php +++ b/resources/views/emails/application-deployment-success.blade.php @@ -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 }})