From 955243fd4a1928ba267662df64d8e0f7d1f8d334 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mauricio=20L=C3=B3pez=20Coria?= Date: Wed, 5 Aug 2026 11:15:48 -0300 Subject: [PATCH] fix: preservar mee/blog/.well-known/design-system en deploy-webhook.php --- src/forms/deploy-webhook.php | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/forms/deploy-webhook.php b/src/forms/deploy-webhook.php index 0d36825..b537eb3 100644 --- a/src/forms/deploy-webhook.php +++ b/src/forms/deploy-webhook.php @@ -41,6 +41,23 @@ $publicHtml = '/home/hostingd/public_html'; $projectSrc = '/root/opencode/development/hostingdelsur.net'; $srcForms = $projectSrc . '/src/forms'; +// Directorios/archivos que NO pertenecen al build de Astro y deben +// sobrevivir el wipe (mismo criterio que scripts/deploy.sh --exclude). +// Se mueven a un staging dir antes del rm -rf y se restauran después. +$preserve = ['mwp', 'mee', 'blog', 'design-system', '.well-known', '.smtp-credentials.json']; +$stagingDir = '/home/hostingd/.deploy-preserve-tmp'; + +$preserveOut = "rm -rf {$stagingDir} && mkdir -p {$stagingDir}"; +foreach ($preserve as $item) { + $preserveOut .= " && [ -e {$publicHtml}/{$item} ] && mv {$publicHtml}/{$item} {$stagingDir}/{$item} || true"; +} + +$restoreOut = ""; +foreach ($preserve as $item) { + $restoreOut .= "[ -e {$stagingDir}/{$item} ] && mv {$stagingDir}/{$item} {$publicHtml}/{$item} || true; "; +} +$restoreOut .= "rm -rf {$stagingDir}"; + $commands = [ "cd {$projectDir} && git pull origin main 2>&1", "cd {$projectDir} && npm install --production=false 2>&1", @@ -48,10 +65,10 @@ $commands = [ "cp {$srcForms}/contact.php {$distDir}/api/contact.php 2>&1", "cp {$srcForms}/deploy-webhook.php {$distDir}/api/deploy-webhook.php 2>&1", "cp {$srcForms}/api-htaccess {$distDir}/api/.htaccess 2>&1", + "{$preserveOut} 2>&1", "rm -rf {$publicHtml}/* {$publicHtml}/.[!.]* 2>&1; mkdir -p {$publicHtml}", "cp -r {$distDir}/* {$distDir}/.[!.]* {$publicHtml}/ 2>&1", - "rm -rf {$publicHtml}/mwp 2>&1 || true", - "rm -f {$publicHtml}/.smtp-credentials.json 2>&1 || true", + "{$restoreOut} 2>&1", ]; foreach ($commands as $cmd) {