mirror of
https://github.com/frappe/frappe_docker.git
synced 2026-06-17 13:55:08 +00:00
conditions are fixed in remove site yml
This commit is contained in:
parent
5f001f71e0
commit
fa09ba9ff3
1 changed files with 40 additions and 39 deletions
79
.github/workflows/remove-site.yml
vendored
79
.github/workflows/remove-site.yml
vendored
|
|
@ -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
|
||||
"
|
||||
|
|
|
|||
Loading…
Reference in a new issue