fix: remove legacy CMS health checks and update verification routes
This commit is contained in:
@@ -238,11 +238,6 @@ jobs:
|
|||||||
TRAEFIK_HOST: ${{ needs.prepare.outputs.traefik_host }}
|
TRAEFIK_HOST: ${{ needs.prepare.outputs.traefik_host }}
|
||||||
GATEKEEPER_HOST: ${{ needs.prepare.outputs.gatekeeper_host }}
|
GATEKEEPER_HOST: ${{ needs.prepare.outputs.gatekeeper_host }}
|
||||||
|
|
||||||
# Secrets mapping (Payload CMS)
|
|
||||||
PAYLOAD_SECRET: ${{ secrets.PAYLOAD_SECRET || vars.PAYLOAD_SECRET || 'you-need-to-set-a-payload-secret' }}
|
|
||||||
PAYLOAD_DB_NAME: ${{ secrets.PAYLOAD_DB_NAME || vars.PAYLOAD_DB_NAME || 'payload' }}
|
|
||||||
PAYLOAD_DB_USER: ${{ secrets.PAYLOAD_DB_USER || vars.PAYLOAD_DB_USER || 'payload' }}
|
|
||||||
PAYLOAD_DB_PASSWORD: ${{ (needs.prepare.outputs.target == 'testing' && secrets.TESTING_PAYLOAD_DB_PASSWORD) || (needs.prepare.outputs.target == 'staging' && secrets.STAGING_PAYLOAD_DB_PASSWORD) || secrets.PAYLOAD_DB_PASSWORD || vars.PAYLOAD_DB_PASSWORD || 'payload' }}
|
|
||||||
|
|
||||||
# Secrets mapping (Mail)
|
# Secrets mapping (Mail)
|
||||||
MAIL_HOST: ${{ secrets.SMTP_HOST || vars.SMTP_HOST }}
|
MAIL_HOST: ${{ secrets.SMTP_HOST || vars.SMTP_HOST }}
|
||||||
@@ -304,11 +299,6 @@ jobs:
|
|||||||
echo "MAIL_FROM=$MAIL_FROM"
|
echo "MAIL_FROM=$MAIL_FROM"
|
||||||
echo "MAIL_RECIPIENTS=$MAIL_RECIPIENTS"
|
echo "MAIL_RECIPIENTS=$MAIL_RECIPIENTS"
|
||||||
echo ""
|
echo ""
|
||||||
echo "# Payload CMS"
|
|
||||||
echo "PAYLOAD_SECRET=$PAYLOAD_SECRET"
|
|
||||||
echo "PAYLOAD_DB_NAME=$PAYLOAD_DB_NAME"
|
|
||||||
echo "PAYLOAD_DB_USER=$PAYLOAD_DB_USER"
|
|
||||||
echo "PAYLOAD_DB_PASSWORD=$PAYLOAD_DB_PASSWORD"
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "# Gatekeeper"
|
echo "# Gatekeeper"
|
||||||
echo "GATEKEEPER_PASSWORD=$GATEKEEPER_PASSWORD"
|
echo "GATEKEEPER_PASSWORD=$GATEKEEPER_PASSWORD"
|
||||||
@@ -367,51 +357,6 @@ jobs:
|
|||||||
ssh root@alpha.mintel.me "cd $SITE_DIR && docker compose -p '${{ needs.prepare.outputs.project_name }}' --env-file '$ENV_FILE' pull"
|
ssh root@alpha.mintel.me "cd $SITE_DIR && docker compose -p '${{ needs.prepare.outputs.project_name }}' --env-file '$ENV_FILE' pull"
|
||||||
ssh root@alpha.mintel.me "cd $SITE_DIR && docker compose -p '${{ needs.prepare.outputs.project_name }}' --env-file '$ENV_FILE' up -d --remove-orphans"
|
ssh root@alpha.mintel.me "cd $SITE_DIR && docker compose -p '${{ needs.prepare.outputs.project_name }}' --env-file '$ENV_FILE' up -d --remove-orphans"
|
||||||
|
|
||||||
# Sanitize Payload Migrations: Replace 'dev' push entries with proper migration names.
|
|
||||||
# Without this, Payload prompts interactively for confirmation and blocks forever in Docker.
|
|
||||||
DB_CONTAINER="${{ needs.prepare.outputs.project_name }}-klz-db-1"
|
|
||||||
echo "⏳ Waiting for database container to be ready..."
|
|
||||||
for i in $(seq 1 15); do
|
|
||||||
if ssh root@alpha.mintel.me "docker exec $DB_CONTAINER pg_isready -U payload -q 2>/dev/null"; then
|
|
||||||
echo "✅ Database is ready."
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
echo " Attempt $i/15..."
|
|
||||||
sleep 2
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "🔧 Sanitizing payload_migrations table (if exists)..."
|
|
||||||
REMOTE_DB_USER=$(ssh root@alpha.mintel.me "grep -h '^PAYLOAD_DB_USER=' $SITE_DIR/.env* 2>/dev/null | tail -1 | cut -d= -f2" || echo "payload")
|
|
||||||
REMOTE_DB_NAME=$(ssh root@alpha.mintel.me "grep -h '^PAYLOAD_DB_NAME=' $SITE_DIR/.env* 2>/dev/null | tail -1 | cut -d= -f2" || echo "payload")
|
|
||||||
REMOTE_DB_USER="${REMOTE_DB_USER:-payload}"
|
|
||||||
REMOTE_DB_NAME="${REMOTE_DB_NAME:-payload}"
|
|
||||||
|
|
||||||
# Auto-detect migrations from src/migrations/*.ts
|
|
||||||
BATCH=1
|
|
||||||
VALUES=""
|
|
||||||
for f in $(ls src/migrations/*.ts 2>/dev/null | sort); do
|
|
||||||
NAME=$(basename "$f" .ts)
|
|
||||||
[ -n "$VALUES" ] && VALUES="$VALUES,"
|
|
||||||
VALUES="$VALUES ('$NAME', $BATCH)"
|
|
||||||
((BATCH++))
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ -n "$VALUES" ]; then
|
|
||||||
ssh root@alpha.mintel.me "docker exec $DB_CONTAINER psql -U $REMOTE_DB_USER -d $REMOTE_DB_NAME -c \"
|
|
||||||
DO \\\$\\\$ BEGIN
|
|
||||||
DELETE FROM payload_migrations WHERE batch = -1;
|
|
||||||
INSERT INTO payload_migrations (name, batch)
|
|
||||||
SELECT name, batch FROM (VALUES $VALUES) AS v(name, batch)
|
|
||||||
WHERE NOT EXISTS (SELECT 1 FROM payload_migrations pm WHERE pm.name = v.name);
|
|
||||||
EXCEPTION WHEN undefined_table THEN
|
|
||||||
RAISE NOTICE 'payload_migrations table does not exist yet — skipping sanitization';
|
|
||||||
END \\\$\\\$;
|
|
||||||
\"" || echo "⚠️ Migration sanitization skipped (table may not exist yet)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Restart app to pick up clean migration state
|
|
||||||
APP_CONTAINER="${{ needs.prepare.outputs.project_name }}-klz-app-1"
|
|
||||||
ssh root@alpha.mintel.me "docker restart $APP_CONTAINER"
|
|
||||||
|
|
||||||
ssh root@alpha.mintel.me "docker system prune -f --filter 'until=24h'"
|
ssh root@alpha.mintel.me "docker system prune -f --filter 'until=24h'"
|
||||||
|
|
||||||
@@ -484,33 +429,6 @@ jobs:
|
|||||||
[ -f /usr/bin/chromium ] && ln -sf /usr/bin/chromium /usr/bin/google-chrome
|
[ -f /usr/bin/chromium ] && ln -sf /usr/bin/chromium /usr/bin/google-chrome
|
||||||
[ -f /usr/bin/chromium ] && ln -sf /usr/bin/chromium /usr/bin/chromium-browser
|
[ -f /usr/bin/chromium ] && ln -sf /usr/bin/chromium /usr/bin/chromium-browser
|
||||||
|
|
||||||
# ── Critical Smoke Tests (MUST pass) ──────────────────────────────────
|
|
||||||
- name: 🏥 CMS Deep Health Check
|
|
||||||
continue-on-error: true
|
|
||||||
env:
|
|
||||||
DEPLOY_URL: ${{ needs.prepare.outputs.next_public_url }}
|
|
||||||
GK_PASS: ${{ secrets.GATEKEEPER_PASSWORD || 'klz2026' }}
|
|
||||||
run: |
|
|
||||||
echo "Waiting 60s for app to fully start (cold start / migrations / hydration)..."
|
|
||||||
sleep 60
|
|
||||||
|
|
||||||
echo "Checking basic health..."
|
|
||||||
curl -sfL --retry 5 --retry-delay 10 "$DEPLOY_URL/health" || { echo "❌ Basic health check failed after retries"; exit 1; }
|
|
||||||
echo "✅ Basic health OK"
|
|
||||||
|
|
||||||
echo "Checking CMS DB connectivity..."
|
|
||||||
# We use -v to see if we hit Gatekeeper (307) or 503/504
|
|
||||||
URL="$DEPLOY_URL/api/health/cms?gk_bypass=$GK_PASS&cb=$(date +%s)"
|
|
||||||
RESPONSE=$(curl -sfL --retry 5 --retry-delay 10 "$URL" 2>&1) || {
|
|
||||||
echo "⚠️ CMS health check failed, but site might still be fine."
|
|
||||||
echo "--- DEBUG INFO ---"
|
|
||||||
curl -svI "$URL"
|
|
||||||
echo "--- RESPONSE BODY ---"
|
|
||||||
curl -sL "$URL" | head -c 1000
|
|
||||||
echo ""
|
|
||||||
echo "Proceeding to smoke tests to confirm actual site functionality."
|
|
||||||
}
|
|
||||||
echo "✅ CMS health output: $RESPONSE"
|
|
||||||
|
|
||||||
|
|
||||||
- name: 🚀 OG Image Check
|
- name: 🚀 OG Image Check
|
||||||
|
|||||||
@@ -350,66 +350,7 @@ async function main() {
|
|||||||
hasErrors = true;
|
hasErrors = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. Cleanup: Delete test submissions from Payload CMS
|
console.log(`\n🧹 Skipping cleanup (No CMS/DB active in this infrastructure).`);
|
||||||
console.log(`\n🧹 Starting cleanup of test submissions...`);
|
|
||||||
const payloadSecret = process.env.PAYLOAD_SECRET;
|
|
||||||
|
|
||||||
if (!payloadSecret) {
|
|
||||||
console.warn(
|
|
||||||
` ⚠️ PAYLOAD_SECRET not found in environment. Cleanup will likely fail with 403 if the server expects a secret.`,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
console.log(
|
|
||||||
` 🔐 PAYLOAD_SECRET found (${payloadSecret.substring(0, 3)}...). Sending x-e2e-secret header.`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
const apiUrl = `${targetUrl.replace(/\/$/, '')}/api/form-submissions`;
|
|
||||||
// We fetch ALL submissions matching the test email to clean up potential lefovers from previous runs
|
|
||||||
const searchUrl = `${apiUrl}?where[email][equals]=testing@mintel.me&limit=100`;
|
|
||||||
|
|
||||||
// Fetch test submissions with bypass header
|
|
||||||
const searchResponse = await axios.get(searchUrl, {
|
|
||||||
headers: {
|
|
||||||
Cookie: `klz_gatekeeper_session=${gatekeeperPassword}`,
|
|
||||||
'x-e2e-secret': payloadSecret || '',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const testSubmissions = searchResponse.data.docs || [];
|
|
||||||
console.log(` Found ${testSubmissions.length} test submissions to clean up.`);
|
|
||||||
|
|
||||||
for (const doc of testSubmissions) {
|
|
||||||
try {
|
|
||||||
await axios.delete(`${apiUrl}/${doc.id}`, {
|
|
||||||
headers: {
|
|
||||||
Cookie: `klz_gatekeeper_session=${gatekeeperPassword}`,
|
|
||||||
'x-e2e-secret': payloadSecret || '',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
console.log(` ✅ Deleted submission: ${doc.id} (${doc.name})`);
|
|
||||||
} catch (delErr: any) {
|
|
||||||
console.warn(` ⚠️ Cleanup attempt on ${doc.id} failed: ${delErr.message}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (testSubmissions.length > 0) {
|
|
||||||
console.log(`✅ Cleanup completed successfully.`);
|
|
||||||
}
|
|
||||||
} catch (err: any) {
|
|
||||||
if (err.response?.status === 403) {
|
|
||||||
console.error(` ❌ Cleanup failed with 403 Forbidden.`);
|
|
||||||
console.error(` Detail: The server rejected the x-e2e-secret header.`);
|
|
||||||
console.error(` Server Response: ${JSON.stringify(err.response.data)}`);
|
|
||||||
} else {
|
|
||||||
console.error(` ❌ Cleanup fetch failed: ${err.message}`);
|
|
||||||
if (err.response) {
|
|
||||||
console.error(` Status: ${err.response.status}`);
|
|
||||||
console.error(` Body: ${JSON.stringify(err.response.data)}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
await browser.close();
|
await browser.close();
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ const routes = [
|
|||||||
'/de/opengraph-image',
|
'/de/opengraph-image',
|
||||||
'/en/opengraph-image',
|
'/en/opengraph-image',
|
||||||
'/de/blog/opengraph-image',
|
'/de/blog/opengraph-image',
|
||||||
'/de/api/og/product?slug=low-voltage-cables',
|
'/de/kontakt/opengraph-image',
|
||||||
'/en/api/og/product?slug=medium-voltage-cables',
|
'/en/contact/opengraph-image',
|
||||||
];
|
];
|
||||||
|
|
||||||
async function verifyImage(path: string): Promise<boolean> {
|
async function verifyImage(path: string): Promise<boolean> {
|
||||||
|
|||||||
Reference in New Issue
Block a user