fix(preview): docker compose preview URLs (#7959)
This commit is contained in:
parent
b87d54f9e4
commit
650186b1ab
1 changed files with 24 additions and 1 deletions
|
|
@ -47,7 +47,7 @@ public function handle()
|
||||||
match ($this->status) {
|
match ($this->status) {
|
||||||
ProcessStatus::QUEUED => $this->body = "The preview deployment for **{$serviceName}** is queued. ⏳\n\n",
|
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::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::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::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",
|
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');
|
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}) | " : '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue