Skip to content

Commit

Permalink
a
Browse files Browse the repository at this point in the history
  • Loading branch information
maulayyacyber committed Oct 3, 2024
1 parent 719132d commit c8dba77
Showing 1 changed file with 11 additions and 35 deletions.
46 changes: 11 additions & 35 deletions Envoy.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@

<!-- rollback -->
@task('rollback')
echo "Rolling back to previous release"
echo "Starting rollback process"
cd {{ $app_dir }}

# Cek apakah ada symlink current
Expand All @@ -154,33 +154,18 @@
fi

# Ambil rilis saat ini
current_release=$(readlink {{ $app_dir }}/current)

# Ambil semua rilis dan urutkan secara descending
releases=($(ls -dt {{ $releases_dir }}/*))

if [ ${#releases[@]} -lt 2 ]; then
echo "Not enough releases for rollback. Rollback aborted."
exit 1
fi

# Tentukan rilis sebelumnya
for release in "${releases[@]}"; do
if [ "$release" != "$current_release" ]; then
previous_release=$release
break
fi
done
current_release=$(readlink -f {{ $app_dir }}/current)
echo "Current release: $(basename $current_release)"

# Ambil rilis sebelumnya
previous_release=$(ls -dt {{ $releases_dir }}/* | sed -n '2p')

if [ -z "$previous_release" ]; then
echo "No previous release found. Rollback aborted."
exit 1
fi

echo "Rolling back from $(basename $current_release) to $(basename $previous_release)"

# Simpan rilis yang gagal untuk dihapus nanti
failed_release=$current_release
echo "Rolling back to: $(basename $previous_release)"

# Hapus symlink current
rm {{ $app_dir }}/current
Expand All @@ -191,18 +176,9 @@
# Pindah ke rilis sebelumnya
cd $previous_release

# Cek apakah ada migrasi yang perlu di-rollback
echo "Checking for migrations to rollback"
migration_status=$(php artisan migrate:status)
latest_batch=$(echo "$migration_status" | awk '/Ran/ {print $NF}' | sed 's/[][]//g' | sort -rn | head -n1)

if [ -n "$latest_batch" ] && [ "$latest_batch" -gt 1 ]; then
echo "Found migrations to rollback (Batch $latest_batch)"
echo "Rolling back database migrations"
php artisan migrate:rollback
else
echo "No migrations to rollback or only initial migrations present"
fi
# Rollback migrasi
echo "Rolling back last batch of migrations"
php artisan migrate:rollback --force

# Bersihkan cache
echo "Clearing application cache"
Expand All @@ -216,7 +192,7 @@

# Hapus rilis yang gagal
echo "Removing failed release"
rm -rf $failed_release
rm -rf $current_release

echo "Rollback completed successfully"
@endtask

0 comments on commit c8dba77

Please sign in to comment.