From ee3ec495bb50e6b538e00cd5d50f617d97f007d4 Mon Sep 17 00:00:00 2001 From: isaacclad Date: Sat, 6 Jun 2026 21:47:09 +0000 Subject: [PATCH] Allow deploy user to switch current release symlink. Fall back to passwordless sudo when the app root is not writable by the runner. Co-authored-by: Cursor --- deploy/deploy.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/deploy/deploy.sh b/deploy/deploy.sh index 610d618..dc477e2 100755 --- a/deploy/deploy.sh +++ b/deploy/deploy.sh @@ -191,8 +191,21 @@ if ! run_artisan "migrate --force"; then exit 1 fi +switch_current_release() { + if ln -sfnT "$NEW_RELEASE" "$CURRENT_LINK" 2>/dev/null; then + return 0 + fi + + if command -v sudo >/dev/null 2>&1 && sudo -n ln -sfnT "$NEW_RELEASE" "$CURRENT_LINK"; then + return 0 + fi + + echo "Unable to update current release symlink at $CURRENT_LINK" >&2 + return 1 +} + log "Switching current release" -ln -sfnT "$NEW_RELEASE" "$CURRENT_LINK" +switch_current_release log "Optimizing Laravel" if [ -L "$CURRENT_LINK" ] && [ -f "$CURRENT_LINK/artisan" ]; then