conditions are fixed in remove site yml

This commit is contained in:
Mate Majoros 2026-01-12 09:17:41 +02:00
parent 5f001f71e0
commit fa09ba9ff3

View file

@ -173,7 +173,7 @@ jobs:
" "
- name: Remove backup files if needed - name: Remove backup files if needed
if: ${{ github.event.inputs.should_remove_backups == true }} if: ${{ github.event.inputs.should_remove_backups == 'true' }}
run: | run: |
echo "🗑️ Removing backup files for site: ${{ github.event.inputs.site_name }}" echo "🗑️ Removing backup files for site: ${{ github.event.inputs.site_name }}"
echo "Environment: ${{ github.event.inputs.environment }}" echo "Environment: ${{ github.event.inputs.environment }}"
@ -187,46 +187,47 @@ jobs:
- name: Display backup information - name: Display backup information
if: ${{ github.event.inputs.should_remove_backups == false }} if: ${{ github.event.inputs.should_remove_backups == 'false' }}
run: | run: |
# Find and display the latest backup files after removal # Find and display the latest backup files after removal
echo '' echo ''
echo '📦 Searching for the backup created during removal...' echo '📦 Searching for the backup created during removal...'
BACKUP_INFO=\$(docker compose exec -T backend bash -c \" ssh ${{ env.HETZNER_USER }}@${{ env.HETZNER_HOST }} "
cd ~/frappe-bench/archived/sites/${{ github.event.inputs.site_name }}/private/backups 2>/dev/null || exit 1 cd ${{ env.DEPLOY_PATH }}
# Get the latest timestamp (from any file) BACKUP_INFO=\$(docker compose exec -T backend bash -c \"
LATEST_TIMESTAMP=\\\$(ls -t *.sql.gz 2>/dev/null | head -n 1 | cut -d'-' -f1) cd ~/frappe-bench/archived/sites/${{ github.event.inputs.site_name }}/private/backups 2>/dev/null || exit 1
if [ -n \\\"\\\$LATEST_TIMESTAMP\\\" ]; then # Get the latest timestamp (from any file)
echo \\\"TIMESTAMP=\\\$LATEST_TIMESTAMP\\\" LATEST_TIMESTAMP=\\\$(ls -t *.sql.gz 2>/dev/null | head -n 1 | cut -d'-' -f1)
ls -lh \\\${LATEST_TIMESTAMP}-* 2>/dev/null | awk '{print \\\$9, \\\"(\\\"\\\$5\\\")\\\"}' || echo 'No files found'
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 else
echo 'No backups found' echo "⚠️ Could not find the archived backup (but site was removed)"
fi 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