diff --git a/.github/workflows/remove-site.yml b/.github/workflows/remove-site.yml index 68b0d57c..1162a594 100644 --- a/.github/workflows/remove-site.yml +++ b/.github/workflows/remove-site.yml @@ -173,7 +173,7 @@ jobs: " - name: Remove backup files if needed - if: ${{ github.event.inputs.should_remove_backups == true }} + if: ${{ github.event.inputs.should_remove_backups == 'true' }} run: | echo "🗑️ Removing backup files for site: ${{ github.event.inputs.site_name }}" echo "Environment: ${{ github.event.inputs.environment }}" @@ -187,46 +187,47 @@ jobs: - name: Display backup information - if: ${{ github.event.inputs.should_remove_backups == false }} + if: ${{ github.event.inputs.should_remove_backups == 'false' }} run: | # Find and display the latest backup files after removal echo '' echo '📦 Searching for the backup created during removal...' - - BACKUP_INFO=\$(docker compose exec -T backend bash -c \" - cd ~/frappe-bench/archived/sites/${{ github.event.inputs.site_name }}/private/backups 2>/dev/null || exit 1 - - # Get the latest timestamp (from any file) - LATEST_TIMESTAMP=\\\$(ls -t *.sql.gz 2>/dev/null | head -n 1 | cut -d'-' -f1) - - if [ -n \\\"\\\$LATEST_TIMESTAMP\\\" ]; then - echo \\\"TIMESTAMP=\\\$LATEST_TIMESTAMP\\\" - ls -lh \\\${LATEST_TIMESTAMP}-* 2>/dev/null | awk '{print \\\$9, \\\"(\\\"\\\$5\\\")\\\"}' || echo 'No files found' - else - echo 'No backups found' - fi - \") - - if echo "$BACKUP_INFO" | grep -q "TIMESTAMP="; then - ARCHIVED_DIR=$(echo "$BACKUP_INFO" | grep -o "ARCHIVED_DIR=[^ ]*" | cut -d'=' -f2) - TIMESTAMP=$(echo "$BACKUP_INFO" | grep -o "TIMESTAMP=[^ ]*" | cut -d'=' -f2) - - # Extract just the filenames (everything after TIMESTAMP= that looks like a file) - FILES=$(echo "$BACKUP_INFO" | sed 's/.*TIMESTAMP=[^ ]* //' | tr ' ' '\n' | grep "^$TIMESTAMP") - - echo "" - echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" - echo "✅ Site removed successfully!" - echo "" - echo "📦 Backup location:" - echo " ~/frappe-bench/archived/sites/$ARCHIVED_DIR/private/backups/" - echo "" - echo "📋 Backup files (timestamp: $TIMESTAMP):" - echo "$FILES" | sed 's/^/ - /' - echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" - else - echo "⚠️ Could not find the archived backup (but site was removed)" - fi - - + ssh ${{ env.HETZNER_USER }}@${{ env.HETZNER_HOST }} " + cd ${{ env.DEPLOY_PATH }} + + BACKUP_INFO=\$(docker compose exec -T backend bash -c \" + cd ~/frappe-bench/archived/sites/${{ github.event.inputs.site_name }}/private/backups 2>/dev/null || exit 1 + + # Get the latest timestamp (from any file) + LATEST_TIMESTAMP=\\\$(ls -t *.sql.gz 2>/dev/null | head -n 1 | cut -d'-' -f1) + + if [ -n \\\"\\\$LATEST_TIMESTAMP\\\" ]; then + echo \\\"TIMESTAMP=\\\$LATEST_TIMESTAMP\\\" + ls -lh \\\${LATEST_TIMESTAMP}-* 2>/dev/null | awk '{print \\\$9, \\\"(\\\"\\\$5\\\")\\\"}' || echo 'No files found' + else + echo 'No backups found' + fi + \") + + if echo "$BACKUP_INFO" | grep -q "TIMESTAMP="; then + ARCHIVED_DIR=$(echo "$BACKUP_INFO" | grep -o "ARCHIVED_DIR=[^ ]*" | cut -d'=' -f2) + TIMESTAMP=$(echo "$BACKUP_INFO" | grep -o "TIMESTAMP=[^ ]*" | cut -d'=' -f2) + + # Extract just the filenames (everything after TIMESTAMP= that looks like a file) + FILES=$(echo "$BACKUP_INFO" | sed 's/.*TIMESTAMP=[^ ]* //' | tr ' ' '\n' | grep "^$TIMESTAMP") + + echo "" + echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" + echo "✅ Site removed successfully!" + echo "" + echo "📦 Backup location:" + echo " ~/frappe-bench/archived/sites/$ARCHIVED_DIR/private/backups/" + echo "" + echo "📋 Backup files (timestamp: $TIMESTAMP):" + echo "$FILES" | sed 's/^/ - /' + echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" + else + echo "⚠️ Could not find the archived backup (but site was removed)" + fi + "