Files
nexus/.gitea/workflows/deploy.yml
Lars Gebhardt-Kusche f883655b3d
All checks were successful
Deploy / deploy-staging (push) Successful in 6s
Deploy / deploy-production (push) Has been skipped
workflwo
2026-04-11 02:14:48 +02:00

241 lines
7.5 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.
name: Deploy
on:
push:
branches:
- develop
- main
jobs:
deploy-staging:
if: gitea.ref == 'refs/heads/develop'
runs-on: private-server
env:
BASE_DIRS: "src public api partials tools data debug modules"
CONFIG_BASE_DIR: "config"
CONFIG_ENV_DIR: "config/staging"
DEPLOY_ENV: "staging"
LOCAL_ROOT: "/deploy/nexus"
SITE_DOMAIN_DIR: "${{ vars.SITE_DOMAIN_DIR }}"
TARGET_PATH: "/deploy/nexus/staging/"
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
if [ -z "${SITE_DOMAIN_DIR}" ]; then
echo "❌ SITE_DOMAIN_DIR ist leer."
echo " Bitte in Gitea als Repository Variable setzen."
exit 1
fi
echo "Deploy Domain: ${SITE_DOMAIN_DIR}"
echo "Target path: ${TARGET_PATH}"
echo "=== DEBUG: who/where ==="
hostname || true
id || true
echo "GITEA_REPOSITORY=${GITEA_REPOSITORY:-}"
echo "GITEA_REF=${GITEA_REF:-}"
echo "=== DEBUG: mount + path visibility ==="
ls -la /deploy || true
ls -la /deploy/webserver || true
df -h /deploy/webserver || true
mount | grep -E "/deploy/webserver" || true
echo "=== DEBUG: write test (pre-sync) ==="
mkdir -p "${TARGET_PATH}"
date > "${TARGET_PATH}/__ci_write_test.txt" || true
ls -la "${TARGET_PATH}" || true
cat "${TARGET_PATH}/__ci_write_test.txt" || true
echo "📁 Prüfe lokale Basisverzeichnisse..."
MISSING=0
for d in $BASE_DIRS; do
if [ ! -d "$d" ]; then
echo "❌ Verzeichnis '$d/' fehlt im Repo!"
MISSING=1
fi
done
if [ ! -d "$CONFIG_BASE_DIR" ]; then
echo "❌ Basis-Konfig-Verzeichnis '$CONFIG_BASE_DIR/' fehlt!"
MISSING=1
fi
if [ ! -d "$CONFIG_ENV_DIR" ]; then
echo "❌ Env-Konfiguration '$CONFIG_ENV_DIR/' fehlt!"
MISSING=1
fi
if [ "$MISSING" -ne 0 ]; then
echo "⛔ Abbruch wegen fehlender Verzeichnisse."
exit 1
fi
echo "🧱 Stelle sicher, dass Zielpfad existiert..."
mkdir -p "${TARGET_PATH}"
echo "🚀 Deploy ${DEPLOY_ENV} → ${TARGET_PATH}"
for d in $BASE_DIRS; do
echo "🔁 Sync ${d}/ → ${TARGET_PATH}${d}/"
mkdir -p "${TARGET_PATH}${d}/"
rsync -a --delete --exclude=".gitkeep" "${d}/" "${TARGET_PATH}${d}/"
done
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
for f in ${CONFIG_BASE_DIR}/*.php; do
if [ -f "$f" ]; then
echo " Basis-Config-Datei: $f"
cp "$f" .ci_config_deploy/
fi
done
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}/"
echo "=== DEBUG: post-sync spot checks ==="
ls -la "${TARGET_PATH}" | head -n 200 || true
find "${TARGET_PATH}" -maxdepth 2 -type f | head -n 200 || true
echo "✅ Deploy ${DEPLOY_ENV} abgeschlossen."
deploy-production:
if: gitea.ref == 'refs/heads/main'
runs-on: private-server
env:
BASE_DIRS: "src public api partials tools data debug modules"
CONFIG_BASE_DIR: "config"
CONFIG_ENV_DIR: "config/prod"
DEPLOY_ENV: "production"
LOCAL_ROOT: "/deploy/nexus"
SITE_DOMAIN_DIR: "${{ vars.SITE_DOMAIN_DIR }}"
TARGET_PATH: "/deploy/nexus/live/"
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
if [ -z "${SITE_DOMAIN_DIR}" ]; then
echo "❌ SITE_DOMAIN_DIR ist leer."
echo " Bitte in Gitea als Repository Variable setzen."
exit 1
fi
echo "Deploy Domain: ${SITE_DOMAIN_DIR}"
echo "Target path: ${TARGET_PATH}"
echo "=== DEBUG: who/where ==="
hostname || true
id || true
echo "GITEA_REPOSITORY=${GITEA_REPOSITORY:-}"
echo "GITEA_REF=${GITEA_REF:-}"
echo "=== DEBUG: mount + path visibility ==="
ls -la /deploy || true
ls -la /deploy/webserver || true
df -h /deploy/webserver || true
mount | grep -E "/deploy/webserver" || true
echo "=== DEBUG: write test (pre-sync) ==="
mkdir -p "${TARGET_PATH}"
date > "${TARGET_PATH}/__ci_write_test.txt" || true
ls -la "${TARGET_PATH}" || true
cat "${TARGET_PATH}/__ci_write_test.txt" || true
echo "📁 Prüfe lokale Basisverzeichnisse..."
MISSING=0
for d in $BASE_DIRS; do
if [ ! -d "$d" ]; then
echo "❌ Verzeichnis '$d/' fehlt im Repo!"
MISSING=1
fi
done
if [ ! -d "$CONFIG_BASE_DIR" ]; then
echo "❌ Basis-Konfig-Verzeichnis '$CONFIG_BASE_DIR/' fehlt!"
MISSING=1
fi
if [ ! -d "$CONFIG_ENV_DIR" ]; then
echo "❌ Env-Konfiguration '$CONFIG_ENV_DIR/' fehlt!"
MISSING=1
fi
if [ "$MISSING" -ne 0 ]; then
echo "⛔ Abbruch wegen fehlender Verzeichnisse."
exit 1
fi
echo "🧱 Stelle sicher, dass Zielpfad existiert..."
mkdir -p "${TARGET_PATH}"
echo "🚀 Deploy ${DEPLOY_ENV} → ${TARGET_PATH}"
for d in $BASE_DIRS; do
echo "🔁 Sync ${d}/ → ${TARGET_PATH}${d}/"
mkdir -p "${TARGET_PATH}${d}/"
rsync -a --delete --exclude=".gitkeep" "${d}/" "${TARGET_PATH}${d}/"
done
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
for f in ${CONFIG_BASE_DIR}/*.php; do
if [ -f "$f" ]; then
echo " Basis-Config-Datei: $f"
cp "$f" .ci_config_deploy/
fi
done
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}/"
echo "=== DEBUG: post-sync spot checks ==="
ls -la "${TARGET_PATH}" | head -n 200 || true
find "${TARGET_PATH}" -maxdepth 2 -type f | head -n 200 || true
echo "✅ Deploy ${DEPLOY_ENV} abgeschlossen."