#!/usr/bin/env bash set -euo pipefail # ============================================================================= # deploy-github-push.sh # Pusht den aktuellen main-Branch an das Forgejo-Remote der Zielinstanz. # # Verwendung: ./deploy-github-push.sh # Beispiel: ./deploy-github-push.sh audit # ============================================================================= SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # --- Kontext laden --- source "${SCRIPT_DIR}/ssh_context.sh" "$@" # --- SSH (Key wird geladen, Passphrase einmalig abgefragt) --- setup_ssh # --- Git-Push --- echo "" echo "=== Code-Deployment ===" echo "Target: ${TARGET} (${DOMAIN})" echo "Remote: ${GIT_REMOTE}" echo "" echo "Pruefe Git-Remote '${GIT_REMOTE}'..." if ! git remote get-url "${GIT_REMOTE}" &>/dev/null; then echo "FEHLER: Git-Remote '${GIT_REMOTE}' existiert nicht." echo "Verfuegbare Remotes:" git remote -v exit 1 fi echo "Starte Push: main -> ${GIT_REMOTE}..." git push "${GIT_REMOTE}" main --force PUSH_EXIT=$? if [ $PUSH_EXIT -ne 0 ]; then echo "FEHLER: Git-Push fehlgeschlagen (Exit-Code: ${PUSH_EXIT})." exit 1 fi echo "" echo "=== Code-Deployment fuer '${TARGET}' abgeschlossen ==="