mirror of
https://github.com/appwrite/appwrite
synced 2026-05-24 09:28:40 +00:00
commit
2fa3ca27af
1 changed files with 29 additions and 24 deletions
|
|
@ -747,6 +747,13 @@ class Builds extends Action
|
||||||
if ($separator !== false) {
|
if ($separator !== false) {
|
||||||
$logs = \substr($logs, 0, $separator);
|
$logs = \substr($logs, 0, $separator);
|
||||||
$insideSeparation = true;
|
$insideSeparation = true;
|
||||||
|
|
||||||
|
$leftover = \substr($logs, $separator + strlen('{APPWRITE_DETECTION_SEPARATOR_START}'));
|
||||||
|
$separator = \strpos($leftover, '{APPWRITE_DETECTION_SEPARATOR_END}');
|
||||||
|
if ($separator !== false) {
|
||||||
|
$logs .= \substr($leftover, $separator + strlen('{APPWRITE_DETECTION_SEPARATOR_END}'));
|
||||||
|
$insideSeparation = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$separator = \strpos($logs, '{APPWRITE_DETECTION_SEPARATOR_END}');
|
$separator = \strpos($logs, '{APPWRITE_DETECTION_SEPARATOR_END}');
|
||||||
|
|
@ -829,18 +836,10 @@ class Builds extends Action
|
||||||
|
|
||||||
// Separate logs for SSR detection
|
// Separate logs for SSR detection
|
||||||
$detectionLogs = '';
|
$detectionLogs = '';
|
||||||
$separator = \strpos($logs, '{APPWRITE_DETECTION_SEPARATOR_START}');
|
if (\str_contains($logs, '{APPWRITE_DETECTION_SEPARATOR_START}')) {
|
||||||
if ($separator !== false) {
|
[$logsBefore, $detectionLogsStart] = \explode('{APPWRITE_DETECTION_SEPARATOR_START}', $logs, 2);
|
||||||
$detectionLogs = \substr($logs, $separator + strlen('{APPWRITE_DETECTION_SEPARATOR}'));
|
[$detectionLogs, $logsAfter] = \explode('{APPWRITE_DETECTION_SEPARATOR_END}', $detectionLogsStart, 2);
|
||||||
$separatorEnd = \strpos($detectionLogs, '{APPWRITE_DETECTION_SEPARATOR_END}');
|
$logs = ($logsBefore ?? '') . ($logsAfter ?? '');
|
||||||
$logs .= \substr($detectionLogs, $separatorEnd + strlen('{APPWRITE_DETECTION_SEPARATOR_END}'));
|
|
||||||
$detectionLogs = \substr($detectionLogs, 0, $separatorEnd);
|
|
||||||
$logs = \substr($logs, 0, $separator);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($resource->getCollection() === 'sites') {
|
|
||||||
$date = \date('H:i:s');
|
|
||||||
$logs .= "[90m[$date] [90m[[0mappwrite[90m][97m Screenshot capturing started. [0m\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$deployment->setAttribute('buildLogs', $logs);
|
$deployment->setAttribute('buildLogs', $logs);
|
||||||
|
|
@ -870,16 +869,24 @@ class Builds extends Action
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$deployment->setAttribute('buildLogs', $logs);
|
|
||||||
|
|
||||||
$this->afterBuildSuccess($dbForProject, $deployment);
|
|
||||||
|
|
||||||
$deployment = $dbForProject->updateDocument('deployments', $deployment->getId(), $deployment);
|
$deployment = $dbForProject->updateDocument('deployments', $deployment->getId(), $deployment);
|
||||||
|
|
||||||
$queueForRealtime
|
$queueForRealtime
|
||||||
->setPayload($deployment->getArrayCopy())
|
->setPayload($deployment->getArrayCopy())
|
||||||
->trigger();
|
->trigger();
|
||||||
|
|
||||||
|
$this->afterBuildSuccess($queueForRealtime, $dbForProject, $deployment);
|
||||||
|
$logs = $deployment->getAttribute('buildLogs', '');
|
||||||
|
|
||||||
|
if ($resource->getCollection() === 'sites') {
|
||||||
|
$date = \date('H:i:s');
|
||||||
|
$logs .= "[90m[$date] [90m[[0mappwrite[90m][97m Screenshot capturing started. [0m\n";
|
||||||
|
$deployment->setAttribute('buildLogs', $logs);
|
||||||
|
$deployment = $dbForProject->updateDocument('deployments', $deployment->getId(), $deployment);
|
||||||
|
$queueForRealtime
|
||||||
|
->setPayload($deployment->getArrayCopy())
|
||||||
|
->trigger();
|
||||||
|
}
|
||||||
|
|
||||||
/** Screenshot site */
|
/** Screenshot site */
|
||||||
if ($resource->getCollection() === 'sites') {
|
if ($resource->getCollection() === 'sites') {
|
||||||
try {
|
try {
|
||||||
|
|
@ -1227,12 +1234,8 @@ class Builds extends Action
|
||||||
$message = "[31m" . $message;
|
$message = "[31m" . $message;
|
||||||
}
|
}
|
||||||
|
|
||||||
$separator = \strpos($message, '{APPWRITE_DETECTION_SEPARATOR_START}');
|
$message = \str_replace('{APPWRITE_DETECTION_SEPARATOR_START}', '', $message);
|
||||||
if ($separator !== false) {
|
$message = \str_replace('{APPWRITE_DETECTION_SEPARATOR_END}', '', $message);
|
||||||
$error = \substr($message, $separator + strlen('{APPWRITE_DETECTION_SEPARATOR_START}'));
|
|
||||||
$message = \substr($message, 0, $separator);
|
|
||||||
$message .= "\n[31m" . $error;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Combine with previous logs if deployment got past build process
|
// Combine with previous logs if deployment got past build process
|
||||||
$previousLogs = '';
|
$previousLogs = '';
|
||||||
|
|
@ -1321,12 +1324,14 @@ class Builds extends Action
|
||||||
/**
|
/**
|
||||||
* Hook to run after build success
|
* Hook to run after build success
|
||||||
*
|
*
|
||||||
|
* @param Realtime $queueForRealtime
|
||||||
* @param Database $dbForProject
|
* @param Database $dbForProject
|
||||||
* @param Document $deployment
|
* @param Document $deployment
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function afterBuildSuccess(Database $dbForProject, Document &$deployment): void
|
protected function afterBuildSuccess(Realtime $queueForRealtime, Database $dbForProject, Document &$deployment): void
|
||||||
{
|
{
|
||||||
|
assert($queueForRealtime instanceof Realtime);
|
||||||
assert($dbForProject instanceof Database);
|
assert($dbForProject instanceof Database);
|
||||||
assert($deployment instanceof Document);
|
assert($deployment instanceof Document);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue