ci(config): master despliega en master.localesp.es y alias rama -> entorno
- scripts/entornos.env: alta de master=/administrador. LOCALESP_ADMIN_PREFIX es obligatoria; sin esta línea el build de master fallaba (y con él el despliegue). - scripts/entornos.alias.env + EnvSlug::environment: mapping <slug-rama>=<slug-entorno> para cuando el DNS sólo tiene un subdominio (prototipo-ef -> prototipo-yb01.localesp.es). Sin alias se mantiene el comportamiento histórico <rama>.localesp.es. - .gitea/workflows/deploy.yml: el prefijo admin del build se resuelve también con el alias, para que build y deploy coincidan siempre.
This commit is contained in:
+21
-1
@@ -25,6 +25,7 @@
|
||||
DOMAIN="localesp.es"
|
||||
PORT_BASE=8082 # 8080/8081 son entornos legacy
|
||||
ENV_CONFIG_FILE="scripts/entornos.env" # mapping slug=prefijo admin (fichero del repo)
|
||||
ENV_ALIAS_FILE="scripts/entornos.alias.env" # mapping slug-rama=slug-entorno (fichero del repo)
|
||||
LOGGER_TAG="env"
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -50,6 +51,25 @@ Slug::from() {
|
||||
printf '%s' "$branch" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9]+/-/g; s/^-+//; s/-+$//'
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# EnvSlug — servicio estático: alias rama -> entorno.
|
||||
# ---------------------------------------------------------------------------
|
||||
# scripts/entornos.alias.env mapea <slug-rama>=<slug-entorno>. Con alias, la
|
||||
# rama reutiliza host, unit, puerto, destino y vhost del entorno indicado; sin
|
||||
# alias, el entorno es la propia rama (comportamiento histórico).
|
||||
EnvSlug::environment() {
|
||||
local slug="$1"
|
||||
local root="${2:-.}"
|
||||
local alias
|
||||
|
||||
alias="$(grep -E "^[[:space:]]*${slug}[[:space:]]*=" "$root/$ENV_ALIAS_FILE" 2>/dev/null | tail -1 | cut -d= -f2- | tr -d '[:space:]')"
|
||||
if [ -n "$alias" ]; then
|
||||
printf '%s' "$alias"
|
||||
else
|
||||
printf '%s' "$slug"
|
||||
fi
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Host — servicio estático: IP pública y resolución DNS.
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -394,7 +414,7 @@ Env::new() {
|
||||
|
||||
s[branch]="$branch"
|
||||
s[root]="$root"
|
||||
s[slug]="$(Slug::from "$branch")"
|
||||
s[slug]="$(EnvSlug::environment "$(Slug::from "$branch")" "$root")"
|
||||
if [ -z "${s[slug]}" ]; then
|
||||
Logger::error "slug vacío para la rama '$branch'"
|
||||
exit 2
|
||||
|
||||
Reference in New Issue
Block a user