From 28822be822e27fec96bc43fbe6ac0c3f73f43841 Mon Sep 17 00:00:00 2001 From: "Somhairle H. Marisol" Date: Sat, 19 Sep 2026 19:45:36 +0800 Subject: fix(deploy): retain the active release when rollback fails [Problem] - Failed rollback could delete a directory still used by current. [Root Cause] - Failure cleanup did not check the active symlink target. [Solution] - Preserve release directories still referenced by current. - Document the self-hosted publishing and manual rollback procedure. [Impact] - Blog deployment cleanup is safer; article content remains unchanged. --- deploy/scripts/build.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'deploy/scripts/build.sh') diff --git a/deploy/scripts/build.sh b/deploy/scripts/build.sh index b76d6ec0..e598700a 100755 --- a/deploy/scripts/build.sh +++ b/deploy/scripts/build.sh @@ -113,12 +113,22 @@ while :; do && echo "rolled back to $prev" >> "$LOG" \ || echo "ROLLBACK FAILED: current -> $DEST_NAME stays" >> "$LOG" fi - rm -rf -- "$RELEASES/$DEST_NAME" + live=$(readlink "$RELEASES/current" 2>/dev/null || true) + if [ "$live" != "$DEST_NAME" ]; then + rm -rf -- "$RELEASES/$DEST_NAME" + else + echo "kept $DEST_NAME: current still points at it" >> "$LOG" + fi RC_LAST=1 fi fi if [ "$OK" -eq 0 ]; then - rm -rf -- "$RELEASES/$DEST_NAME" + live=$(readlink "$RELEASES/current" 2>/dev/null || true) + if [ "$live" != "$DEST_NAME" ]; then + rm -rf -- "$RELEASES/$DEST_NAME" + else + echo "kept $DEST_NAME: current still points at it" >> "$LOG" + fi echo "==== build $TS FAILED at publish, previous release kept ====" >> "$LOG" RC_LAST=1 fi -- cgit v1.2.3