mirror of
https://github.com/appwrite/appwrite
synced 2026-05-24 01:18:37 +00:00
Fix commit deployments, allow for sites
This commit is contained in:
parent
bfdd2b65dc
commit
c5dfabdb7c
4 changed files with 28 additions and 25 deletions
12
composer.lock
generated
12
composer.lock
generated
|
|
@ -4855,16 +4855,16 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "utopia-php/vcs",
|
"name": "utopia-php/vcs",
|
||||||
"version": "0.9.3",
|
"version": "0.9.4",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/utopia-php/vcs.git",
|
"url": "https://github.com/utopia-php/vcs.git",
|
||||||
"reference": "865a00c67e81a20938b883f9aa802303790dd3b5"
|
"reference": "1a8d280b176acc99ea8d9e7364b8767cbb206b4a"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/utopia-php/vcs/zipball/865a00c67e81a20938b883f9aa802303790dd3b5",
|
"url": "https://api.github.com/repos/utopia-php/vcs/zipball/1a8d280b176acc99ea8d9e7364b8767cbb206b4a",
|
||||||
"reference": "865a00c67e81a20938b883f9aa802303790dd3b5",
|
"reference": "1a8d280b176acc99ea8d9e7364b8767cbb206b4a",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
|
@ -4899,9 +4899,9 @@
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/utopia-php/vcs/issues",
|
"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",
|
"name": "utopia-php/websocket",
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ namespace Appwrite\Platform\Modules\Compute;
|
||||||
use Appwrite\Event\Build;
|
use Appwrite\Event\Build;
|
||||||
use Appwrite\Extend\Exception;
|
use Appwrite\Extend\Exception;
|
||||||
use Appwrite\Query;
|
use Appwrite\Query;
|
||||||
use Utopia\CLI\Console;
|
|
||||||
use Utopia\Database\Database;
|
use Utopia\Database\Database;
|
||||||
use Utopia\Database\Document;
|
use Utopia\Database\Document;
|
||||||
use Utopia\Database\Helpers\ID;
|
use Utopia\Database\Helpers\ID;
|
||||||
|
|
@ -39,25 +38,29 @@ class Base extends Action
|
||||||
throw new Exception(Exception::PROVIDER_REPOSITORY_NOT_FOUND);
|
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') {
|
if ($referenceType === 'branch') {
|
||||||
$providerBranch = empty($reference) ? $function->getAttribute('providerBranch', 'main') : $reference;
|
$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";
|
$authorUrl = "https://github.com/$owner";
|
||||||
$repositoryUrl = "https://github.com/$owner/$repositoryName";
|
$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([
|
$deployment = $dbForProject->createDocument('deployments', new Document([
|
||||||
'$id' => $deploymentId,
|
'$id' => $deploymentId,
|
||||||
|
|
|
||||||
|
|
@ -59,9 +59,9 @@ class Create extends Base
|
||||||
],
|
],
|
||||||
))
|
))
|
||||||
->param('functionId', '', new UID(), 'Function ID.')
|
->param('functionId', '', new UID(), 'Function ID.')
|
||||||
// TODO: Support tag and commit in future
|
// TODO: Support tag in future
|
||||||
->param('type', '', new WhiteList(['branch']), 'Type of reference passed. Allowed values are: branch')
|
->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')
|
->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)
|
->param('activate', false, new Boolean(), 'Automatically activate the deployment when it is finished building.', true)
|
||||||
->inject('request')
|
->inject('request')
|
||||||
->inject('response')
|
->inject('response')
|
||||||
|
|
|
||||||
|
|
@ -60,8 +60,8 @@ class Create extends Base
|
||||||
))
|
))
|
||||||
->param('siteId', '', new UID(), 'Site ID.')
|
->param('siteId', '', new UID(), 'Site ID.')
|
||||||
// TODO: Support tag in future
|
// TODO: Support tag in future
|
||||||
->param('type', '', new WhiteList(['branch', 'commit']), 'Type of reference passed. Allowed values are: branch')
|
->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')
|
->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)
|
->param('activate', false, new Boolean(), 'Automatically activate the deployment when it is finished building.', true)
|
||||||
->inject('request')
|
->inject('request')
|
||||||
->inject('response')
|
->inject('response')
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue