refactor(update scripts): enhance directory handling and error management
Some checks failed
Deploy to production / deploy (push) Failing after 1m46s

- Updated update-backend.sh and update-frontend.sh to accept a target directory as a parameter, improving flexibility.
- Refactored paths to use the target directory for all operations, ensuring consistency and reducing hardcoded values.
- Added error handling with 'set -euo pipefail' for better script reliability.
- Improved user feedback by displaying the target directory during updates.
This commit is contained in:
Torsten Schulz (local)
2026-03-30 13:19:11 +02:00
parent 5001292616
commit b2591da428
4 changed files with 71 additions and 37 deletions

23
deploy-yourpart-bluegreen.sh Executable file
View File

@@ -0,0 +1,23 @@
#!/usr/bin/env bash
# Blue-Green: Deploy in einen Slot (TARGET), ohne /opt/yourpart als echtes Verzeichnis anzulegen.
# Live-Umschaltung: ln -sfn <slot> /opt/yourpart
#
# Aufruf (auf dem Server, im Repo-Root nach git pull):
# ./deploy-yourpart-bluegreen.sh /opt/yourpart-green
#
# Voraussetzung: /opt/yourpart ist ein Symlink auf den aktiven Slot.
set -euo pipefail
CURRENT_LINK="${CURRENT_LINK:-/opt/yourpart}"
TARGET="${1:?Ziel-Slot-Verzeichnis fehlt (z. B. /opt/yourpart-green)}"
if [ ! -L "$CURRENT_LINK" ]; then
echo "❌ ERROR: $CURRENT_LINK ist kein Symlink! (Blue-Green erfordert Symlink auf den aktiven Slot.)" >&2
exit 1
fi
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
exec ./update.sh "$TARGET"