Files
nexus/.gitlab-ci.yml
2026-03-06 23:53:25 +01:00

113 lines
3.6 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:
# CONFIG wird separat gemischt und nach /config synchronisiert
BASE_DIRS: "api data debug modules partials public src 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 Workspace (ohne config/) ---
echo "🔁 Sync Workspace → ${TARGET_PATH} (ohne config/)"
chmod -R u+rwX,go+rX "${TARGET_PATH}" || true
rsync -a --delete --inplace \
--no-owner --no-group --no-perms --omit-dir-times \
--chmod=Du=rwx,Dgo=rx,Fu=rw,Fgo=r \
--exclude=".git" \
--exclude=".ci_config_deploy" \
--exclude="config/" \
--exclude=".gitlab-ci.yml" \
--exclude="README.md" \
--exclude="PROJECT_CONTEXT.md" \
--exclude=".gitkeep" \
"./" "${TARGET_PATH}"
# --- 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
# --- Ensure env subdirs are removed on target ---
echo "🧹 Entferne ${TARGET_PATH}${CONFIG_BASE_DIR}/prod und /staging falls vorhanden..."
rm -rf "${TARGET_PATH}${CONFIG_BASE_DIR}/prod" "${TARGET_PATH}${CONFIG_BASE_DIR}/staging"
echo "🔁 Sync .ci_config_deploy/ → ${TARGET_PATH}${CONFIG_BASE_DIR}/"
mkdir -p "${TARGET_PATH}${CONFIG_BASE_DIR}/"
rsync -a --delete --inplace \
--no-owner --no-group --no-perms --omit-dir-times \
--chmod=Du=rwx,Dgo=rx,Fu=rw,Fgo=r \
--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}/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}/live/"
environment:
name: production
only:
- main
# when: manual