Support commit type

This commit is contained in:
Matej Bačo 2025-03-13 11:17:10 +01:00
parent 69ed3bb776
commit 8376b176cb
4 changed files with 32 additions and 28 deletions

24
composer.lock generated
View file

@ -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",

View file

@ -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', ''))) {

View file

@ -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')

View file

@ -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',
])