name: Deploy on: push: branches: - develop - main jobs: deploy-staging: if: gitea.ref == 'refs/heads/develop' runs-on: private-server env: ENSURE_DIRS: "src public api partials tools data debug modules config" CONFIG_BASE_DIR: "config" CONFIG_ENV_DIR: "config/staging" DEPLOY_ENV: "staging" TARGET_PATH: "/deploy/nexus/desktop/staging/" RSYNC_OPTS: "--delete --inplace --no-whole-file --no-owner --no-group --no-perms --omit-dir-times --chmod=Du=rwx,Dgo=rx,Fu=rw,Fgo=r" steps: - name: Checkout uses: actions/checkout@v4 - name: Debug workspace run: | echo "Workspace:" && pwd ls -la - name: Deploy staging shell: bash run: | set -euo pipefail echo "🚀 Deploy ${DEPLOY_ENV} → ${TARGET_PATH}" mkdir -p "${TARGET_PATH}" echo "🧱 Stelle lokale Standardverzeichnisse sicher..." for d in $ENSURE_DIRS; do if [ ! -d "$d" ]; then echo "➕ Erstelle fehlendes Verzeichnis: $d" mkdir -p "$d" fi done if [ ! -d "$CONFIG_ENV_DIR" ]; then echo "➕ Erstelle fehlendes Env-Config-Verzeichnis: $CONFIG_ENV_DIR" mkdir -p "$CONFIG_ENV_DIR" fi echo "🔁 Sync gesamtes Projekt → ${TARGET_PATH}" rsync -a ${RSYNC_OPTS} \ --exclude=".git/***" \ --exclude=".gitea/***" \ --exclude=".ci_config_deploy/***" \ --exclude="data/***" \ --exclude="docs/***" \ --exclude="Customimport/***" \ --exclude="temp/***" \ --exclude="CopyToKeycloak/***" \ --exclude="Umsetzungsanweisung/***" \ --exclude="config/staging/***" \ --exclude="config/prod/***" \ --exclude="skins/**/vendor/***" \ --exclude=".gitkeep" \ ./ "${TARGET_PATH}" echo "🧩 Baue gemischtes Config-Verzeichnis..." rm -rf .ci_config_deploy mkdir -p .ci_config_deploy for f in ${CONFIG_BASE_DIR}/*.php; do if [ -f "$f" ]; then echo "➕ Basis-Config-Datei: $f" cp "$f" .ci_config_deploy/ fi done if [ -d "${CONFIG_ENV_DIR}" ]; then echo "➕ Env-Config aus ${CONFIG_ENV_DIR}/" cp -R "${CONFIG_ENV_DIR}/." .ci_config_deploy/ fi echo "🔁 Sync Config → ${TARGET_PATH}${CONFIG_BASE_DIR}/" mkdir -p "${TARGET_PATH}${CONFIG_BASE_DIR}/" rsync -a ${RSYNC_OPTS} \ --exclude=".gitkeep" \ ".ci_config_deploy/" "${TARGET_PATH}${CONFIG_BASE_DIR}/" echo "✅ Deploy ${DEPLOY_ENV} abgeschlossen." deploy-production: if: gitea.ref == 'refs/heads/main' runs-on: private-server env: ENSURE_DIRS: "src public api partials tools data debug modules config" CONFIG_BASE_DIR: "config" CONFIG_ENV_DIR: "config/prod" DEPLOY_ENV: "production" TARGET_PATH: "/deploy/nexus/desktop/live/" RSYNC_OPTS: "--delete --inplace --no-whole-file --no-owner --no-group --no-perms --omit-dir-times --chmod=Du=rwx,Dgo=rx,Fu=rw,Fgo=r" steps: - name: Checkout uses: actions/checkout@v4 - name: Debug workspace run: | echo "Workspace:" && pwd ls -la - name: Deploy production shell: bash run: | set -euo pipefail echo "🚀 Deploy ${DEPLOY_ENV} → ${TARGET_PATH}" mkdir -p "${TARGET_PATH}" echo "🧱 Stelle lokale Standardverzeichnisse sicher..." for d in $ENSURE_DIRS; do if [ ! -d "$d" ]; then echo "➕ Erstelle fehlendes Verzeichnis: $d" mkdir -p "$d" fi done if [ ! -d "$CONFIG_ENV_DIR" ]; then echo "➕ Erstelle fehlendes Env-Config-Verzeichnis: $CONFIG_ENV_DIR" mkdir -p "$CONFIG_ENV_DIR" fi echo "🔁 Sync gesamtes Projekt → ${TARGET_PATH}" rsync -a ${RSYNC_OPTS} \ --exclude=".git/***" \ --exclude=".gitea/***" \ --exclude=".ci_config_deploy/***" \ --exclude="data/***" \ --exclude="docs/***" \ --exclude="temp/***" \ --exclude="Customimport/***" \ --exclude="CopyToKeycloak/***" \ --exclude="Umsetzungsanweisung/***" \ --exclude="config/staging/***" \ --exclude="config/prod/***" \ --exclude="skins/**/vendor/***" \ --exclude=".gitkeep" \ ./ "${TARGET_PATH}" echo "🧩 Baue gemischtes Config-Verzeichnis..." rm -rf .ci_config_deploy mkdir -p .ci_config_deploy for f in ${CONFIG_BASE_DIR}/*.php; do if [ -f "$f" ]; then echo "➕ Basis-Config-Datei: $f" cp "$f" .ci_config_deploy/ fi done if [ -d "${CONFIG_ENV_DIR}" ]; then echo "➕ Env-Config aus ${CONFIG_ENV_DIR}/" cp -R "${CONFIG_ENV_DIR}/." .ci_config_deploy/ fi echo "🔁 Sync Config → ${TARGET_PATH}${CONFIG_BASE_DIR}/" mkdir -p "${TARGET_PATH}${CONFIG_BASE_DIR}/" rsync -a ${RSYNC_OPTS} \ --exclude=".gitkeep" \ ".ci_config_deploy/" "${TARGET_PATH}${CONFIG_BASE_DIR}/" echo "✅ Deploy ${DEPLOY_ENV} abgeschlossen."