diff --git a/app/Jobs/ApplicationPullRequestUpdateJob.php b/app/Jobs/ApplicationPullRequestUpdateJob.php index 05453b6a3..025daa12b 100755 --- a/app/Jobs/ApplicationPullRequestUpdateJob.php +++ b/app/Jobs/ApplicationPullRequestUpdateJob.php @@ -47,7 +47,7 @@ public function handle() match ($this->status) { ProcessStatus::QUEUED => $this->body = "The preview deployment for **{$serviceName}** is queued. ⏳\n\n", ProcessStatus::IN_PROGRESS => $this->body = "The preview deployment for **{$serviceName}** is in progress. 🟡\n\n", - ProcessStatus::FINISHED => $this->body = "The preview deployment for **{$serviceName}** is ready. 🟢\n\n".($this->preview->fqdn ? "[Open Preview]({$this->preview->fqdn}) | " : ''), + ProcessStatus::FINISHED => $this->body = "The preview deployment for **{$serviceName}** is ready. 🟢\n\n".$this->getPreviewLinks(), ProcessStatus::ERROR => $this->body = "The preview deployment for **{$serviceName}** failed. 🔴\n\n", ProcessStatus::KILLED => $this->body = "The preview deployment for **{$serviceName}** was killed. ⚫\n\n", ProcessStatus::CANCELLED => $this->body = "The preview deployment for **{$serviceName}** was cancelled. 🚫\n\n", @@ -91,4 +91,27 @@ private function delete_comment() { githubApi(source: $this->application->source, endpoint: "/repos/{$this->application->git_repository}/issues/comments/{$this->preview->pull_request_issue_comment_id}", method: 'delete'); } + + private function getPreviewLinks(): string + { + if ($this->application->build_pack === 'dockercompose') { + $dockerComposeDomains = json_decode($this->preview->docker_compose_domains, true) ?? []; + $links = []; + + foreach ($dockerComposeDomains as $serviceName => $config) { + $domain = data_get($config, 'domain'); + if (! empty($domain)) { + $firstDomain = str($domain)->explode(',')->first(); + $firstDomain = trim($firstDomain); + if (! empty($firstDomain)) { + $links[] = "[Open {$serviceName}]({$firstDomain})"; + } + } + } + + return ! empty($links) ? implode(' | ', $links).' | ' : ''; + } + + return $this->preview->fqdn ? "[Open Preview]({$this->preview->fqdn}) | " : ''; + } }