Files
nexus/.gitlab-ci.yml
2026-03-01 23:44:49 +01:00

99 lines
3.0 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
stages:
- deploy
variables:
BASE_DIRS: "src public api partials tools"
CONFIG_BASE_DIR: "config"
LOCAL_ROOT: "/mnt/nexusserver"
# SITE_DOMAIN_DIR wurde entfernt
default:
image: alpine:3.20
.deploy_local_template:
stage: deploy
before_script:
- apk add --no-cache rsync bash coreutils
- echo "CI Workspace:" && pwd && ls -la
script:
- |
set -e
echo "Deploy ENV: ${DEPLOY_ENV}"
echo "Target path: ${TARGET_PATH}"
# =========================================================
# DEBUG: Check mount points
# =========================================================
echo "=== DEBUG: nexusserver visibility ==="
ls -la /mnt || true
ls -la /mnt/nexusserver || true
df -h /mnt/nexusserver || true
# --- Ensure target exists ---
echo "🧱 Stelle sicher, dass Zielpfad existiert..."
mkdir -p "${TARGET_PATH}"
echo "🚀 Deploy ${DEPLOY_ENV} → ${TARGET_PATH}"
# --- Sync base dirs ---
for d in $BASE_DIRS; do
if [ -d "$d" ]; then
echo "🔁 Sync ${d}/ → ${TARGET_PATH}${d}/"
mkdir -p "${TARGET_PATH}${d}/"
rsync -a --delete --exclude=".gitkeep" "${d}/" "${TARGET_PATH}${d}/"
else
echo "⚠️ Verzeichnis $d existiert nicht im Repo, überspringe Sync."
fi
done
# --- Build mixed config ---
echo "🧩 Baue gemischtes Config-Verzeichnis (config/*.php + ${CONFIG_ENV_DIR})..."
rm -rf .ci_config_deploy
mkdir -p .ci_config_deploy
if [ -d "${CONFIG_BASE_DIR}" ]; then
# Kopiere Basis-PHP-Dateien falls vorhanden
find "${CONFIG_BASE_DIR}" -maxdepth 1 -name "*.php" -exec cp {} .ci_config_deploy/ \;
fi
if [ -d "${CONFIG_ENV_DIR}" ]; then
echo " Env-Config aus ${CONFIG_ENV_DIR}/"
cp -R "${CONFIG_ENV_DIR}/." .ci_config_deploy/
fi
echo "🔁 Sync .ci_config_deploy/ → ${TARGET_PATH}${CONFIG_BASE_DIR}/"
mkdir -p "${TARGET_PATH}${CONFIG_BASE_DIR}/"
rsync -a --delete --exclude=".gitkeep" ".ci_config_deploy/" "${TARGET_PATH}${CONFIG_BASE_DIR}/"
# =========================================================
# DEBUG: Verifikation
# =========================================================
echo "=== DEBUG: post-sync spot checks ==="
ls -la "${TARGET_PATH}" | head -n 50 || true
echo "✅ Deploy ${DEPLOY_ENV} abgeschlossen."
deploy:staging:
extends: .deploy_local_template
variables:
DEPLOY_ENV: "staging"
CONFIG_ENV_DIR: "config/staging"
TARGET_PATH: "${LOCAL_ROOT}/nexus/staging/"
environment:
name: staging
# url: https://staging.deine-domain.de # Hier ggf. manuell anpassen
only:
- develop
- merge_requests
deploy:production:
extends: .deploy_local_template
variables:
DEPLOY_ENV: "production"
CONFIG_ENV_DIR: "config/prod"
TARGET_PATH: "${LOCAL_ROOT}/nexus/live/"
environment:
name: production
only:
- main
# when: manual