diff --git a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php
index 11eacb5ec3..43e5bbe876 100644
--- a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php
+++ b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php
@@ -955,9 +955,21 @@ class Builds extends Action
default => throw new \Exception('Invalid resource type')
};
+ $previewUrl = match($resource->getCollection()) {
+ 'functions' => '',
+ 'sites' => $deployment->getAttribute('domain', ''),
+ default => throw new \Exception('Invalid resource type')
+ };
+
+ $previweQrCode = match($resource->getCollection()) {
+ 'functions' => '',
+ 'sites' => 'https://cloud.appwrite.io/v1/avatars/qr?text=' . $previewUrl,
+ default => throw new \Exception('Invalid resource type')
+ };
+
$comment = new Comment();
$comment->parseComment($github->getComment($owner, $repositoryName, $commentId));
- $comment->addBuild($project, $resource, $resourceType, $status, $deployment->getId(), ['type' => 'logs']);
+ $comment->addBuild($project, $resource, $resourceType, $status, $deployment->getId(), ['type' => 'logs'], $previewUrl, $previweQrCode);
$github->updateComment($owner, $repositoryName, $commentId, $comment->generateComment());
} finally {
$dbForConsole->deleteDocument('vcsCommentLocks', $commentId);
diff --git a/src/Appwrite/Vcs/Comment.php b/src/Appwrite/Vcs/Comment.php
index f896fdefc9..f363ad4aed 100644
--- a/src/Appwrite/Vcs/Comment.php
+++ b/src/Appwrite/Vcs/Comment.php
@@ -27,7 +27,7 @@ class Comment
return \count($this->builds) === 0;
}
- public function addBuild(Document $project, Document $resource, string $resourceType, string $buildStatus, string $deploymentId, array $action): void
+ public function addBuild(Document $project, Document $resource, string $resourceType, string $buildStatus, string $deploymentId, array $action, string $previewUrl, string $previewQrCode): void
{
// Unique index
$id = $project->getId() . '_' . $resource->getId();
@@ -41,6 +41,8 @@ class Comment
'buildStatus' => $buildStatus,
'deploymentId' => $deploymentId,
'action' => $action,
+ 'previewQrCode' => $previewQrCode,
+ 'previewUrl' => $previewUrl,
];
}
@@ -67,8 +69,8 @@ class Comment
'status' => $build['buildStatus'],
'deploymentId' => $build['deploymentId'],
'action' => $build['action'],
- 'previewUrl' => 'http://google.com',
- 'previewQrCode' => 'https://cloud.appwrite.io/v1/avatars/qr?text=https://www.google.com/'
+ 'previewUrl' => $build['$previewUrl'],
+ 'previewQrCode' => $build['previewQrCode']
];
} else if($build['resourceType'] === 'function') {
$projects[$build['projectId']]['function'][$build['resourceId']] = [
@@ -86,6 +88,42 @@ class Comment
$text .= "Project name: **{$project['name']}** \nProject ID: `{$projectId}`\n\n";
+ if(\count($project['site']) > 0) {
+
+ $text .= "| Site | ID | Status | Previews | Action |\n";
+ $text .= "| :- | :- | :- | :- | :- |\n";
+
+ foreach ($project['site'] as $siteId => $site) {
+ $generateImage = function (string $status) use ($protocol, $hostname) {
+ $extention = $status === 'building' ? 'gif' : 'png';
+ $imagesUrl = $protocol . '://' . $hostname . '/console/images/vcs/';
+ $imageUrl = '
';
+
+ return $imageUrl;
+ };
+
+ $status = match ($site['status']) {
+ 'waiting' => $generateImage('waiting') . ' Waiting to build',
+ 'processing' => $generateImage('processing') . ' Processing',
+ 'building' => $generateImage('building') . ' Building',
+ 'ready' => $generateImage('ready') . ' Ready',
+ 'failed' => $generateImage('failed') . ' Failed',
+ };
+
+ if ($site['action']['type'] === 'logs') {
+ $action = '[View Logs](' . $protocol . '://' . $hostname . '/console/project-' . $projectId . '/sites/site-' . $siteId . '/deployment-' . $site['deploymentId'] . ')';
+ } else {
+ $action = '[Authorize](' . $site['action']['url'] . ')';
+ }
+
+ $previews = '[Preview URL](' . $site['previewUrl'] . ') [QR Code](' . $site['previewQrCode'] . ')';
+
+ $text .= "| {$site['name']} | `{$siteId}` | {$status} | {$previews} | {$action} |\n";
+ }
+
+ $text .= "\n\n";
+ }
+
if(\count($project['function']) > 0) {
$text .= "| Function | ID | Status | Action |\n";
@@ -115,45 +153,10 @@ class Comment
$text .= "| {$function['name']} | `{$functionId}` | {$status} | {$action} |\n";
}
+
+ $text .= "\n\n";
}
- $text .= "\n\n";
-
- if(\count($project['site']) > 0) {
-
- $text .= "| Site | ID | Status | Previews | Action |\n";
- $text .= "| :- | :- | :- | :- | :- |\n";
-
- foreach ($project['site'] as $siteId => $site) {
- $generateImage = function (string $status) use ($protocol, $hostname) {
- $extention = $status === 'building' ? 'gif' : 'png';
- $imagesUrl = $protocol . '://' . $hostname . '/console/images/vcs/';
- $imageUrl = '
';
-
- return $imageUrl;
- };
-
- $status = match ($site['status']) {
- 'waiting' => $generateImage('waiting') . ' Waiting to build',
- 'processing' => $generateImage('processing') . ' Processing',
- 'building' => $generateImage('building') . ' Building',
- 'ready' => $generateImage('ready') . ' Ready',
- 'failed' => $generateImage('failed') . ' Failed',
- };
-
- if ($site['action']['type'] === 'logs') {
- $action = '[View Logs](' . $protocol . '://' . $hostname . '/console/project-' . $projectId . '/sites/site-' . $siteId . '/deployment-' . $site['deploymentId'] . ')';
- } else {
- $action = '[Authorize](' . $site['action']['url'] . ')';
- }
-
- $previews = '[Preview URL](' . $site['previewUrl'] . ') | [QR Code](' . $site['previewQrCode'] . ')';
-
- $text .= "| {$site['name']} | `{$siteId}` | {$status} | {$previews} | {$action} |\n";
- }
- }
-
- $text .= "\n\n";
}
$text .= "Only deployments on the production branch are activated automatically. Learn more about Appwrite [Functions](https://appwrite.io/docs/functions) and [Sites](https://appwrite.io/docs/sites).\n\n";