mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Merge branch '1.9.x' into feat-x-oauth2-provider
This commit is contained in:
@@ -127,7 +127,6 @@ trait Deployment
|
||||
|
||||
Span::add("{$logBase}.authorized", $isAuthorized);
|
||||
|
||||
$commentStatus = 'waiting';
|
||||
$protocol = System::getEnv('_APP_OPTIONS_FORCE_HTTPS') === 'disabled' ? 'http' : 'https';
|
||||
$hostname = $platform['consoleHostname'] ?? '';
|
||||
|
||||
@@ -135,6 +134,34 @@ trait Deployment
|
||||
|
||||
$action = $isAuthorized ? ['type' => 'logs'] : ['type' => 'authorize', 'url' => $authorizeUrl];
|
||||
|
||||
$commentStatus = 'waiting';
|
||||
$commentPreviewUrl = '';
|
||||
|
||||
// If this action was triggered by pull request, use most up to date details in comment
|
||||
if (!empty($providerPullRequestId)) {
|
||||
$existingDeployment = $authorization->skip(fn () => $dbForProject->findOne('deployments', [
|
||||
Query::equal('resourceInternalId', [$resource->getSequence()]),
|
||||
Query::equal('resourceType', [$resourceCollection]),
|
||||
Query::equal('providerCommitHash', [$providerCommitHash]),
|
||||
Query::equal('providerBranch', [$providerBranch]),
|
||||
Query::orderDesc('$createdAt')
|
||||
]));
|
||||
|
||||
$commentStatus = $existingDeployment->getAttribute('status', 'waiting');
|
||||
|
||||
if ($resource->getCollection() === 'sites') {
|
||||
$previewRule = $authorization->skip(fn () => $dbForPlatform->findOne('rules', [
|
||||
Query::equal('projectInternalId', [$project->getSequence()]),
|
||||
Query::equal('type', ['deployment']), // Not redirect
|
||||
Query::equal('trigger', ['deployment']), // Preview - Not manual
|
||||
Query::equal('deploymentResourceType', ['site']), // Not function
|
||||
Query::equal('deploymentInternalId', [$existingDeployment->getSequence()]),
|
||||
]));
|
||||
|
||||
$commentPreviewUrl = !$previewRule->isEmpty() ? ("{$protocol}://" . $previewRule->getAttribute('domain', '')) : '';
|
||||
}
|
||||
}
|
||||
|
||||
$latestCommentId = '';
|
||||
|
||||
if (!empty($providerPullRequestId) && $resource->getAttribute('providerSilentMode', false) === false) {
|
||||
@@ -173,7 +200,7 @@ trait Deployment
|
||||
try {
|
||||
$comment = new Comment($platform);
|
||||
$comment->parseComment($github->getComment($owner, $repositoryName, $latestCommentId));
|
||||
$comment->addBuild($project, $resource, $resourceType, $commentStatus, $deploymentId, $action, '');
|
||||
$comment->addBuild($project, $resource, $resourceType, $commentStatus, $deploymentId, $action, $commentPreviewUrl);
|
||||
|
||||
$latestCommentId = \strval($github->updateComment($owner, $repositoryName, $latestCommentId, $comment->generateComment()));
|
||||
} finally {
|
||||
@@ -182,7 +209,7 @@ trait Deployment
|
||||
}
|
||||
} else {
|
||||
$comment = new Comment($platform);
|
||||
$comment->addBuild($project, $resource, $resourceType, $commentStatus, $deploymentId, $action, '');
|
||||
$comment->addBuild($project, $resource, $resourceType, $commentStatus, $deploymentId, $action, $commentPreviewUrl);
|
||||
$latestCommentId = \strval($github->createComment($owner, $repositoryName, $providerPullRequestId, $comment->generateComment()));
|
||||
|
||||
if (!empty($latestCommentId)) {
|
||||
@@ -274,6 +301,19 @@ trait Deployment
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!empty($providerPullRequestId)) {
|
||||
// Update comment ID so running build can update comment
|
||||
$authorization->skip(fn () => $dbForProject->updateDocuments('deployments', new Document([
|
||||
'providerCommentId' => \strval($latestCommentId)
|
||||
]), [
|
||||
Query::equal('providerCommitHash', [$providerCommitHash]),
|
||||
Query::equal('providerBranch', [$providerBranch]),
|
||||
]));
|
||||
|
||||
// Skip rest - prevent double deployments (previous one was made by push)
|
||||
continue;
|
||||
}
|
||||
|
||||
$commands = [];
|
||||
if (!empty($resource->getAttribute('installCommand', ''))) {
|
||||
$commands[] = $resource->getAttribute('installCommand', '');
|
||||
|
||||
@@ -65,7 +65,7 @@ class Create extends Action
|
||||
$signature = $request->getHeader('x-hub-signature-256', '');
|
||||
$secretKey = System::getEnv('_APP_VCS_GITHUB_WEBHOOK_SECRET', '');
|
||||
|
||||
$valid = empty($signature) ? true : $github->validateWebhookEvent($payload, $signature, $secretKey);
|
||||
$valid = empty($secretKey) ? true : $github->validateWebhookEvent($payload, $signature, $secretKey);
|
||||
Span::add('vcs.github.event.signature.valid', $valid);
|
||||
|
||||
if (!$valid) {
|
||||
@@ -162,8 +162,8 @@ class Create extends Action
|
||||
Query::limit(100),
|
||||
]));
|
||||
|
||||
// Create new deployment only on push (not committed by us) and not when branch is created or deleted
|
||||
if ($providerCommitAuthorEmail !== APP_VCS_GITHUB_EMAIL && !$providerBranchCreated && !$providerBranchDeleted) {
|
||||
// Create new deployment only on push (not committed by us) and not when branch is deleted
|
||||
if ($providerCommitAuthorEmail !== APP_VCS_GITHUB_EMAIL && !$providerBranchDeleted) {
|
||||
$this->createGitDeployments($github, $providerInstallationId, $repositories, $providerBranch, $providerBranchUrl, $providerRepositoryName, $providerRepositoryUrl, $providerRepositoryOwner, $providerCommitHash, $providerCommitAuthorName, $providerCommitAuthorUrl, $providerCommitMessage, $providerCommitUrl, '', false, $dbForPlatform, $authorization, $queueForBuilds, $getProjectDB, $platform);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user