diff --git a/app/config/collections.php b/app/config/collections.php index 6acbeb31cc..883f947dea 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -2317,7 +2317,7 @@ $collections = [ 'filters' => [], ], [ - '$id' => ID::custom('repoId'), + '$id' => ID::custom('vcsRepoId'), 'type' => Database::VAR_STRING, 'signed' => true, 'size' => 2048, diff --git a/app/controllers/api/vcs.php b/app/controllers/api/vcs.php index c1fbb8a157..acdae154a3 100644 --- a/app/controllers/api/vcs.php +++ b/app/controllers/api/vcs.php @@ -38,7 +38,7 @@ App::get('/v1/vcs/github/installations') ->action(function (Response $response, Document $project) { $projectId = $project->getId(); - $appName = App::getEnv('VCS_GITHUB_NAME', ''); + $appName = App::getEnv('VCS_GITHUB_NAME'); $response->redirect(`https://github.com/apps/"{$appName}"/installations/new?state={$projectId}`); }); @@ -121,9 +121,9 @@ App::get('v1/vcs/github/installations/:installationId/repositories') $privateKey = App::getEnv('VCS_GITHUB_PRIVATE_KEY'); $githubAppId = App::getEnv('VCS_GITHUB_APP_ID'); - //TODO: Update GitHub Username + $githubAppName = App::getEnv('VCS_GITHUB_NAME'); $github = new GitHub(); - $github->initialiseVariables($installationId, $privateKey, $githubAppId, 'vermakhushboo'); + $github->initialiseVariables($installationId, $privateKey, $githubAppId, $githubAppName); $repos = $github->listRepositoriesForGitHubApp(); $response->dynamic(new Document([ @@ -149,6 +149,7 @@ App::post('/v1/vcs/github/incomingwebhook') $github = new GitHub(); $privateKey = App::getEnv('VCS_GITHUB_PRIVATE_KEY'); $githubAppId = App::getEnv('VCS_GITHUB_APP_ID'); + $githubAppName = App::getEnv('VCS_GITHUB_NAME'); $parsedPayload = $github->parseWebhookEventPayload($event, $payload); $parsedPayload = json_decode($parsedPayload, true); @@ -247,7 +248,7 @@ App::post('/v1/vcs/github/incomingwebhook') $installationId = $parsedPayload["installationId"]; $pullRequestNumber = $parsedPayload["pullRequestNumber"]; $repositoryName = $parsedPayload["repositoryName"]; - $github->initialiseVariables($installationId, $privateKey, $githubAppId, 'vermakhushboo'); + $github->initialiseVariables($installationId, $privateKey, $githubAppId, $githubAppName); $vcsRepos = $dbForConsole->find('vcs_repos', [ Query::equal('repositoryId', [$repositoryId]), diff --git a/app/workers/builds.php b/app/workers/builds.php index 8757944207..1a622eea7f 100644 --- a/app/workers/builds.php +++ b/app/workers/builds.php @@ -102,9 +102,10 @@ class BuildsV1 extends Worker $privateKey = App::getEnv('VCS_GITHUB_PRIVATE_KEY'); $githubAppId = App::getEnv('VCS_GITHUB_APP_ID'); + $githubAppName = App::getEnv('VCS_GITHUB_NAME'); $github = new GitHub(); - $github->initialiseVariables($installationId, $privateKey, $githubAppId, 'vermakhushboo'); //TODO: Update GitHub Username + $github->initialiseVariables($installationId, $privateKey, $githubAppId, $githubAppName); $branchName = $deployment->getAttribute('branch'); $gitCloneCommand = $github->generateGitCloneCommand($repositoryId, $branchName); $stdout = ''; diff --git a/app/workers/deletes.php b/app/workers/deletes.php index 7f6cbc12f8..78e7d8d267 100644 --- a/app/workers/deletes.php +++ b/app/workers/deletes.php @@ -809,11 +809,13 @@ class DeletesV1 extends Worker $this->listByGroup('functions', [ Query::equal('vcsInstallationInternalId', [$document->getInternalId()]) ], $dbForProject, function($function) use ($dbForProject) { + $dbForProject->deleteDocument('vcs_repos', $function->getAttribute('vcsRepoId')); + $function = $function ->setAttribute('vcsInstallationId', '') ->setAttribute('vcsInstallationInternalId', '') - ->setAttribute('repoId', '') - ->setAttribute('repoInternalId', ''); + ->setAttribute('vcsRepoId', '') + ->setAttribute('vcsRepoInternalId', ''); $dbForProject->updateDocument('functions', $function->getId(), $function); }); }