From 8376b176cb4e07616cdd99d4e4a854d664ba9b57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Thu, 13 Mar 2025 11:17:10 +0100 Subject: [PATCH] Support commit type --- composer.lock | 24 +++++++-------- .../Platform/Modules/Compute/Base.php | 30 +++++++++++-------- .../Sites/Http/Deployments/Vcs/Create.php | 4 +-- .../Utopia/Response/Model/Deployment.php | 2 +- 4 files changed, 32 insertions(+), 28 deletions(-) diff --git a/composer.lock b/composer.lock index da69c2bb0b..8f8affce93 100644 --- a/composer.lock +++ b/composer.lock @@ -5085,16 +5085,16 @@ "packages-dev": [ { "name": "appwrite/sdk-generator", - "version": "0.40.6", + "version": "0.40.7", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator.git", - "reference": "d8816209a07e7d64ef62dbcaf8ad4aa1262f58b9" + "reference": "9e89b0bc4d8e6c81817d27096629f34a149fa873" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/d8816209a07e7d64ef62dbcaf8ad4aa1262f58b9", - "reference": "d8816209a07e7d64ef62dbcaf8ad4aa1262f58b9", + "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/9e89b0bc4d8e6c81817d27096629f34a149fa873", + "reference": "9e89b0bc4d8e6c81817d27096629f34a149fa873", "shasum": "" }, "require": { @@ -5130,9 +5130,9 @@ "description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms", "support": { "issues": "https://github.com/appwrite/sdk-generator/issues", - "source": "https://github.com/appwrite/sdk-generator/tree/0.40.6" + "source": "https://github.com/appwrite/sdk-generator/tree/0.40.7" }, - "time": "2025-03-10T19:04:24+00:00" + "time": "2025-03-12T08:43:55+00:00" }, { "name": "doctrine/annotations", @@ -5881,16 +5881,16 @@ }, { "name": "phpbench/phpbench", - "version": "1.4.0", + "version": "1.4.1", "source": { "type": "git", "url": "https://github.com/phpbench/phpbench.git", - "reference": "4248817222514421cba466bfa7adc7d8932345d4" + "reference": "78cd98a9aa34e0f8f80ca01972a8b88d2c30194b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpbench/phpbench/zipball/4248817222514421cba466bfa7adc7d8932345d4", - "reference": "4248817222514421cba466bfa7adc7d8932345d4", + "url": "https://api.github.com/repos/phpbench/phpbench/zipball/78cd98a9aa34e0f8f80ca01972a8b88d2c30194b", + "reference": "78cd98a9aa34e0f8f80ca01972a8b88d2c30194b", "shasum": "" }, "require": { @@ -5967,7 +5967,7 @@ ], "support": { "issues": "https://github.com/phpbench/phpbench/issues", - "source": "https://github.com/phpbench/phpbench/tree/1.4.0" + "source": "https://github.com/phpbench/phpbench/tree/1.4.1" }, "funding": [ { @@ -5975,7 +5975,7 @@ "type": "github" } ], - "time": "2025-01-26T19:54:45+00:00" + "time": "2025-03-12T08:01:40+00:00" }, { "name": "phpdocumentor/reflection-common", diff --git a/src/Appwrite/Platform/Modules/Compute/Base.php b/src/Appwrite/Platform/Modules/Compute/Base.php index 192c216a3a..3a58b42d58 100644 --- a/src/Appwrite/Platform/Modules/Compute/Base.php +++ b/src/Appwrite/Platform/Modules/Compute/Base.php @@ -119,25 +119,29 @@ class Base extends Action throw new Exception(Exception::PROVIDER_REPOSITORY_NOT_FOUND); } - // TODO: Support tag and commit in future + $commitDetails = []; + $branchUrl = ""; + $providerBranch = ""; + + // TODO: Support tag in future if ($referenceType === 'branch') { $providerBranch = empty($reference) ? $site->getAttribute('providerBranch', 'main') : $reference; + $branchUrl = "https://github.com/$owner/$repositoryName/tree/$providerBranch"; + try { + $commitDetails = $github->getLatestCommit($owner, $repositoryName, $providerBranch); + } catch (\Throwable $error) { + // Ignore; deployment can continue + } + } elseif ($referenceType === 'commit') { + try { + $commitDetails = $github->getCommit($owner, $repositoryName, $reference); + } catch (\Throwable $error) { + // Ignore; deployment can continue + } } $authorUrl = "https://github.com/$owner"; $repositoryUrl = "https://github.com/$owner/$repositoryName"; - $branchUrl = "https://github.com/$owner/$repositoryName/tree/$providerBranch"; - - $commitDetails = []; - if ($template->isEmpty()) { - try { - $commitDetails = $github->getLatestCommit($owner, $repositoryName, $providerBranch); - } catch (\Throwable $error) { - Console::warning('Failed to get latest commit details'); - Console::warning($error->getMessage()); - Console::warning($error->getTraceAsString()); - } - } $commands = []; if (!empty($site->getAttribute('installCommand', ''))) { diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Vcs/Create.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Vcs/Create.php index 52dc378b48..3cdd7aa7d9 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Vcs/Create.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Vcs/Create.php @@ -59,8 +59,8 @@ class Create extends Base ], )) ->param('siteId', '', new UID(), 'Site ID.') - // TODO: Support tag and commit in future - ->param('type', '', new WhiteList(['branch']), 'Type of reference passed. Allowed values are: branch') + // TODO: Support tag in future + ->param('type', '', new WhiteList(['branch', 'commit']), 'Type of reference passed. Allowed values are: branch') ->param('reference', '', new Text(255), 'VCS reference to create deployment from. Depending on type this can be: branch name') ->param('activate', false, new Boolean(), 'Automatically activate the deployment when it is finished building.', true) ->inject('request') diff --git a/src/Appwrite/Utopia/Response/Model/Deployment.php b/src/Appwrite/Utopia/Response/Model/Deployment.php index 2b14977a7e..8321b548c9 100644 --- a/src/Appwrite/Utopia/Response/Model/Deployment.php +++ b/src/Appwrite/Utopia/Response/Model/Deployment.php @@ -90,7 +90,7 @@ class Deployment extends Model ]) ->addRule('status', [ 'type' => self::TYPE_STRING, - 'description' => 'The deployment status. Possible values are "processing", "building", "waiting", "ready", and "failed".', + 'description' => 'The deployment status. Possible values are "waiting", "processing", "building", "waiting", "ready", and "failed".', 'default' => '', 'example' => 'ready', ])