diff --git a/composer.lock b/composer.lock index 11b687c6ef..5c3c37da54 100644 --- a/composer.lock +++ b/composer.lock @@ -4855,16 +4855,16 @@ }, { "name": "utopia-php/vcs", - "version": "0.9.3", + "version": "0.9.4", "source": { "type": "git", "url": "https://github.com/utopia-php/vcs.git", - "reference": "865a00c67e81a20938b883f9aa802303790dd3b5" + "reference": "1a8d280b176acc99ea8d9e7364b8767cbb206b4a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/vcs/zipball/865a00c67e81a20938b883f9aa802303790dd3b5", - "reference": "865a00c67e81a20938b883f9aa802303790dd3b5", + "url": "https://api.github.com/repos/utopia-php/vcs/zipball/1a8d280b176acc99ea8d9e7364b8767cbb206b4a", + "reference": "1a8d280b176acc99ea8d9e7364b8767cbb206b4a", "shasum": "" }, "require": { @@ -4899,9 +4899,9 @@ ], "support": { "issues": "https://github.com/utopia-php/vcs/issues", - "source": "https://github.com/utopia-php/vcs/tree/0.9.3" + "source": "https://github.com/utopia-php/vcs/tree/0.9.4" }, - "time": "2025-02-26T16:33:35+00:00" + "time": "2025-03-13T10:09:45+00:00" }, { "name": "utopia-php/websocket", diff --git a/src/Appwrite/Platform/Modules/Compute/Base.php b/src/Appwrite/Platform/Modules/Compute/Base.php index 3a58b42d58..178d07b161 100644 --- a/src/Appwrite/Platform/Modules/Compute/Base.php +++ b/src/Appwrite/Platform/Modules/Compute/Base.php @@ -5,7 +5,6 @@ namespace Appwrite\Platform\Modules\Compute; use Appwrite\Event\Build; use Appwrite\Extend\Exception; use Appwrite\Query; -use Utopia\CLI\Console; use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Helpers\ID; @@ -39,25 +38,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) ? $function->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()); - } - } $deployment = $dbForProject->createDocument('deployments', new Document([ '$id' => $deploymentId, diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Vcs/Create.php b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Vcs/Create.php index a47730c053..1e1b6ac1cc 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Vcs/Create.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Vcs/Create.php @@ -59,9 +59,9 @@ class Create extends Base ], )) ->param('functionId', '', new UID(), 'Function ID.') - // TODO: Support tag and commit in future - ->param('type', '', new WhiteList(['branch']), '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') + // TODO: Support tag in future + ->param('type', '', new WhiteList(['branch', 'commit']), 'Type of reference passed. Allowed values are: branch, commit') + ->param('reference', '', new Text(255), 'VCS reference to create deployment from. Depending on type this can be: branch name, commit hash') ->param('activate', false, new Boolean(), 'Automatically activate the deployment when it is finished building.', true) ->inject('request') ->inject('response') 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 3cdd7aa7d9..b0585a27db 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Vcs/Create.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Vcs/Create.php @@ -60,8 +60,8 @@ class Create extends Base )) ->param('siteId', '', new UID(), 'Site ID.') // 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('type', '', new WhiteList(['branch', 'commit', 'tag']), 'Type of reference passed. Allowed values are: branch, commit') + ->param('reference', '', new Text(255), 'VCS reference to create deployment from. Depending on type this can be: branch name, commit hash') ->param('activate', false, new Boolean(), 'Automatically activate the deployment when it is finished building.', true) ->inject('request') ->inject('response')