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.
53 lines
1.4 KiB
Bash
Executable File
53 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
TARGET_DIR="${1:?Zielverzeichnis fehlt: ./update.sh <z. B. /opt/yourpart-green>}"
|
|
|
|
echo "=== YourPart Update Script ==="
|
|
echo "Ziel-Slot: $TARGET_DIR"
|
|
echo "Aktualisiert die Anwendung, ohne .env-Dateien zu überschreiben"
|
|
echo ""
|
|
|
|
# Prüfen ob wir im richtigen Verzeichnis sind
|
|
if [ ! -f "package.json" ]; then
|
|
echo "Error: Please run this script from the YourPart3 root directory"
|
|
exit 1
|
|
fi
|
|
|
|
# Sicherstellen, dass wir wirklich auf main sind
|
|
CURRENT_BRANCH="$(git rev-parse --abbrev-ref HEAD)"
|
|
if [ "$CURRENT_BRANCH" != "main" ]; then
|
|
echo "Error: current branch is '$CURRENT_BRANCH', expected 'main'"
|
|
exit 1
|
|
fi
|
|
|
|
# Remote-Stand holen
|
|
git fetch origin main
|
|
|
|
# Arbeitsbaum hart auf origin/main setzen
|
|
git reset --hard origin/main
|
|
|
|
# Optional: unversionierte Build-Artefakte entfernen
|
|
git clean -fd
|
|
|
|
# Prüfen ob sudo verfügbar ist
|
|
if ! command -v sudo >/dev/null 2>&1; then
|
|
echo "Error: sudo is required but not installed"
|
|
exit 1
|
|
fi
|
|
|
|
echo ""
|
|
echo "=== Updating Backend ==="
|
|
./update-backend.sh "$TARGET_DIR"
|
|
|
|
echo ""
|
|
echo "=== Building and Updating Frontend ==="
|
|
./update-frontend.sh "$TARGET_DIR"
|
|
|
|
echo ""
|
|
echo "=== Update Completed! ==="
|
|
echo "Your application has been updated."
|
|
echo ""
|
|
echo "To check logs:"
|
|
echo " Backend: sudo journalctl -u yourpart.service -f"
|
|
echo " Apache: sudo tail -f /var/log/apache2/yourpart.*.log" |