WIP: Build from template

This commit is contained in:
Khushboo Verma 2023-06-20 12:42:33 +05:30
parent 1b4036078b
commit 399847d7ea
2 changed files with 23 additions and 3 deletions

View file

@ -129,12 +129,32 @@ class BuildsV1 extends Worker
$owner = $github->getOwnerName($installationId);
$repositoryName = $github->getRepositoryName($repositoryId);
$branchName = $deployment->getAttribute('vcsBranch');
$gitCloneCommand = $github->generateGitCloneCommand($owner, $repositoryId, $branchName, $tmpDirectory, $rootDirectory);
$gitCloneCommand = $github->generateGitCloneCommand($owner, $repositoryName, $branchName, $tmpDirectory, $rootDirectory);
\var_dump($gitCloneCommand);
$stdout = '';
$stderr = '';
Console::execute('mkdir -p /tmp/builds/' . $buildId, '', $stdout, $stderr);
Console::execute($gitCloneCommand, '', $stdout, $stderr);
// build from template
$templateRepositoryName = $template->getAttribute('templateRepositoryName');
$templateOwnerName = $template->getAttribute('templateOwnerName');
if (!empty($templateRepositoryName) && !empty($templateOwnerName)) {
// clone template repo
$tmpTemplateDirectory = '/tmp/builds/' . $buildId . '/template';
$templateRootDirectory = $template->getAttribute('templateDirectory', '');
var_dump($templateOwnerName . " " . $templateRepositoryName);
$gitCloneCommandForTemplate = $github->generateGitCloneCommand($templateOwnerName, $templateRepositoryName, 'main', $tmpTemplateDirectory, $templateRootDirectory);
var_dump("clone cmd for template " . $gitCloneCommandForTemplate);
Console::execute($gitCloneCommandForTemplate, '', $stdout, $stderr);
// TODO: move template to code directory
// Console::execute('mv FROM TO', '', $stdout, $stderr);
// TODO: commit and push
}
Console::execute('tar --exclude code.tar.gz -czf /tmp/builds/' . $buildId . '/code.tar.gz -C /tmp/builds/' . $buildId . '/code' . (empty($rootDirectory) ? '' : '/' . $rootDirectory) . ' .', '', $stdout, $stderr);
$deviceFunctions = $this->getFunctionsDevice($project->getId());

4
composer.lock generated
View file

@ -2705,7 +2705,7 @@
"source": {
"type": "git",
"url": "https://github.com/utopia-php/vcs.git",
"reference": "7fb5b733ab0676b257d8bc8fc4e0c4cafd4c756c"
"reference": "df56d0eecf308e0c8b1e86c6801bb44c7c363052"
},
"require": {
"adhocore/jwt": "^1.1",
@ -2750,7 +2750,7 @@
"utopia",
"vcs"
],
"time": "2023-06-17T14:27:48+00:00"
"time": "2023-06-19T16:54:01+00:00"
},
{
"name": "utopia-php/websocket",