chore: purge legacy payload cms and database migration logic
Some checks failed
🚀 Build & Deploy / 🔍 Prepare (push) Successful in 3s
🚀 Build & Deploy / 🧪 QA (push) Successful in 2m37s
🚀 Build & Deploy / 🏗️ Build (push) Successful in 12m11s
🚀 Build & Deploy / 🚀 Deploy (push) Successful in 8s
🚀 Build & Deploy / 🧪 Post-Deploy Verification (push) Successful in 1m3s
🚀 Build & Deploy / 🔔 Notify (push) Successful in 2s
Nightly QA (Inlined) / 🧪 Quality Assurance (push) Failing after 56s
Some checks failed
🚀 Build & Deploy / 🔍 Prepare (push) Successful in 3s
🚀 Build & Deploy / 🧪 QA (push) Successful in 2m37s
🚀 Build & Deploy / 🏗️ Build (push) Successful in 12m11s
🚀 Build & Deploy / 🚀 Deploy (push) Successful in 8s
🚀 Build & Deploy / 🧪 Post-Deploy Verification (push) Successful in 1m3s
🚀 Build & Deploy / 🔔 Notify (push) Successful in 2s
Nightly QA (Inlined) / 🧪 Quality Assurance (push) Failing after 56s
This commit is contained in:
@@ -244,14 +244,7 @@ jobs:
|
||||
IMAGE_TAG: ${{ needs.prepare.outputs.image_tag }}
|
||||
PROJECT_NAME: ${{ needs.prepare.outputs.project_name }}
|
||||
NEXT_PUBLIC_BASE_URL: ${{ needs.prepare.outputs.next_public_url }}
|
||||
|
||||
# Secrets mapping (Database & CMS)
|
||||
PAYLOAD_SECRET: ${{ (needs.prepare.outputs.target == 'testing' && secrets.TESTING_PAYLOAD_SECRET) || (needs.prepare.outputs.target == 'staging' && secrets.STAGING_PAYLOAD_SECRET) || secrets.PAYLOAD_SECRET || secrets.MINTEL_PRIVATE_TOKEN || secrets.DIRECTUS_SECRET || vars.PAYLOAD_SECRET || 'you-need-to-set-a-payload-secret' }}
|
||||
DATABASE_URI: ${{ (needs.prepare.outputs.target == 'testing' && secrets.TESTING_DATABASE_URI) || (needs.prepare.outputs.target == 'staging' && secrets.STAGING_DATABASE_URI) || secrets.DATABASE_URI || vars.DATABASE_URI }}
|
||||
POSTGRES_DB: ${{ secrets.POSTGRES_DB || vars.POSTGRES_DB || 'payload' }}
|
||||
POSTGRES_USER: ${{ secrets.POSTGRES_USER || vars.POSTGRES_USER || 'directus' }}
|
||||
POSTGRES_PASSWORD: ${{ (needs.prepare.outputs.target == 'testing' && secrets.TESTING_POSTGRES_PASSWORD) || (needs.prepare.outputs.target == 'staging' && secrets.STAGING_POSTGRES_PASSWORD) || secrets.POSTGRES_PASSWORD || vars.POSTGRES_PASSWORD || 'directus' }}
|
||||
|
||||
MINTEL_PRIVATE_TOKEN: ${{ secrets.MINTEL_PRIVATE_TOKEN }}
|
||||
|
||||
# Secrets mapping (Mail)
|
||||
MAIL_HOST: ${{ secrets.SMTP_HOST || vars.SMTP_HOST }}
|
||||
@@ -309,13 +302,6 @@ jobs:
|
||||
PROJECT_COLOR=$PROJECT_COLOR
|
||||
LOG_LEVEL=$LOG_LEVEL
|
||||
|
||||
# Database & Payload
|
||||
DATABASE_URI=\${DATABASE_URI:-postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@mb-grid-db:5432/$POSTGRES_DB}
|
||||
PAYLOAD_SECRET=${PAYLOAD_SECRET:-you-need-to-set-a-payload-secret}
|
||||
POSTGRES_DB=$POSTGRES_DB
|
||||
POSTGRES_USER=$POSTGRES_USER
|
||||
POSTGRES_PASSWORD=$POSTGRES_PASSWORD
|
||||
|
||||
# Mail
|
||||
MAIL_HOST=$MAIL_HOST
|
||||
MAIL_PORT=$MAIL_PORT
|
||||
@@ -364,28 +350,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' up -d --remove-orphans"
|
||||
|
||||
# Apply Payload Migrations using the target app container's programmatic endpoint
|
||||
ssh root@alpha.mintel.me "cd $SITE_DIR && echo '→ Waiting for DB and Running Payload Migrations...' && \
|
||||
for i in {1..15}; do \
|
||||
echo \"Attempt \$i...\"; \
|
||||
docker compose -p '${{ needs.prepare.outputs.project_name }}' --env-file '$ENV_FILE' exec -T mb-grid-app sh -c 'curl -s -i -X POST -H \"Authorization: Bearer \$PAYLOAD_SECRET\" http://localhost:3000/api/payload/migrate' > /tmp/migrate_res 2>&1; \
|
||||
if grep -q \"200 OK\" /tmp/migrate_res; then \
|
||||
echo \"✅ Migrations successful!\"; \
|
||||
cat /tmp/migrate_res; \
|
||||
break; \
|
||||
else \
|
||||
echo \"❌ Attempt \$i failed. Response:\"; \
|
||||
cat /tmp/migrate_res; \
|
||||
if [ \$i -eq 15 ]; then \
|
||||
echo \"❌ Migration failed after 15 attempts! Dumping app logs...\"; \
|
||||
docker compose -p '${{ needs.prepare.outputs.project_name }}' --env-file '$ENV_FILE' logs --tail 100 mb-grid-app; \
|
||||
exit 1; \
|
||||
fi; \
|
||||
echo \"⏳ Retrying in 5s...\"; \
|
||||
sleep 5; \
|
||||
fi; \
|
||||
done"
|
||||
|
||||
ssh root@alpha.mintel.me "docker system prune -f --filter 'until=24h'"
|
||||
|
||||
- name: 🧹 Post-Deploy Cleanup (Runner)
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# ────────────────────────────────────────────────────────────────────────────
|
||||
# Payload CMS Database Backup
|
||||
# Creates a timestamped pg_dump of the Payload Postgres database.
|
||||
# Usage: npm run backup:db
|
||||
# ────────────────────────────────────────────────────────────────────────────
|
||||
set -euo pipefail
|
||||
|
||||
# Load environment variables
|
||||
if [ -f .env ]; then
|
||||
set -a; source .env; set +a
|
||||
fi
|
||||
|
||||
# Fallback for local development if not in .env
|
||||
DB_NAME="${POSTGRES_DB:-payload}"
|
||||
DB_USER="${POSTGRES_USER:-postgres}"
|
||||
# For production, we need the container name.
|
||||
# We'll use the PROJECT_NAME to find it if possible, otherwise use a default.
|
||||
PROJECT_NAME="${PROJECT_NAME:-mb-grid-solutions-production}"
|
||||
DB_CONTAINER="${DB_CONTAINER:-${PROJECT_NAME}-mb-grid-db-1}"
|
||||
BACKUP_DIR="./backups"
|
||||
TIMESTAMP=$(date +"%Y%m%d_%H%M%S")
|
||||
BACKUP_FILE="${BACKUP_DIR}/payload_${TIMESTAMP}.sql.gz"
|
||||
|
||||
# Ensure backup directory exists
|
||||
mkdir -p "$BACKUP_DIR"
|
||||
|
||||
# Check if container is running
|
||||
if ! docker ps --format '{{.Names}}' | grep -q "$DB_CONTAINER"; then
|
||||
echo "❌ Database container '$DB_CONTAINER' is not running."
|
||||
echo " Check your docker-compose status."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "📦 Backing up Payload database..."
|
||||
echo " Container: $DB_CONTAINER"
|
||||
echo " Database: $DB_NAME"
|
||||
echo " Output: $BACKUP_FILE"
|
||||
|
||||
# Run pg_dump inside the container and compress
|
||||
# We use directus as user for now if we haven't fully switched to postgres user in all environments
|
||||
# But the script should be consistent with the environment.
|
||||
docker exec "$DB_CONTAINER" pg_dump -U "$DB_USER" -d "$DB_NAME" --clean --if-exists | gzip > "$BACKUP_FILE"
|
||||
|
||||
# Show result
|
||||
SIZE=$(du -h "$BACKUP_FILE" | cut -f1)
|
||||
echo ""
|
||||
echo "✅ Backup complete: $BACKUP_FILE ($SIZE)"
|
||||
echo ""
|
||||
|
||||
# Show existing backups
|
||||
echo "📋 Available backups:"
|
||||
ls -lh "$BACKUP_DIR"/*.sql.gz 2>/dev/null | awk '{print " " $NF " (" $5 ")"}'
|
||||
Reference in New Issue
Block a user