feat: script de promoción manual de Staging a Producción
Contraparte del cambio en apps-registry/.gitea/workflows/build.yaml: desde ahora el CI solo actualiza Staging automáticamente en cada push. Este script lee la versión actual en workloads/ecommerce-staging/frontend/patches/deployment.yaml y la aplica a workloads/ecommerce/frontend/patches/deployment.yaml (con confirmación interactiva), commiteando y pusheando a apps-registry. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_012Y4df3Z7odr9Cg8F2nw6uV
This commit is contained in:
1 parent
78b97bdd59
commit
3640cd5754
1 file changed
+60
Executable
+60
@@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env bash
|
||||
set -Eeuo pipefail
|
||||
|
||||
# Promueve el tag de imagen del frontend actualmente desplegado en Staging
|
||||
# (workloads/ecommerce-staging/frontend/patches/deployment.yaml) al
|
||||
# manifiesto real de Producción (workloads/ecommerce/frontend/patches/
|
||||
# deployment.yaml). Es la contraparte manual del job "Actualizar
|
||||
# Manifiesto GitOps (CD)" de .gitea/workflows/build.yaml, que desde
|
||||
# 2026-09-14 solo actualiza Staging automáticamente en cada push a main.
|
||||
#
|
||||
# Asume que este repo (scripts) y apps-registry están clonados como
|
||||
# hermanos bajo el mismo directorio del lab (mismo layout que
|
||||
# lab-cruzcloud/{apps-registry,platform-infra,scripts} en esta NAS).
|
||||
|
||||
APPS_REGISTRY_DIR="${APPS_REGISTRY_DIR:-$(cd "$(dirname "${BASH_SOURCE[0]}")/../apps-registry" && pwd)}"
|
||||
STAGING_MANIFEST="${APPS_REGISTRY_DIR}/workloads/ecommerce-staging/frontend/patches/deployment.yaml"
|
||||
PROD_MANIFEST="${APPS_REGISTRY_DIR}/workloads/ecommerce/frontend/patches/deployment.yaml"
|
||||
IMAGE_NAME="gitea.cruzcloud.net/devops/ecommerce-frontend"
|
||||
|
||||
test -d "${APPS_REGISTRY_DIR}/.git" || {
|
||||
echo "ERROR: no se encontró un checkout de apps-registry en ${APPS_REGISTRY_DIR}."
|
||||
echo "Definí APPS_REGISTRY_DIR=/ruta/al/checkout si no está junto a este repo."
|
||||
exit 1
|
||||
}
|
||||
|
||||
STAGING_VERSION="$(grep -oE "${IMAGE_NAME}:v[0-9.]+" "${STAGING_MANIFEST}" | head -1 | cut -d: -f2)"
|
||||
test -n "${STAGING_VERSION}" || {
|
||||
echo "ERROR: no se pudo leer la versión actual de Staging desde ${STAGING_MANIFEST}."
|
||||
exit 1
|
||||
}
|
||||
|
||||
CURRENT_PROD_VERSION="$(grep -oE "${IMAGE_NAME}:v[0-9.]+" "${PROD_MANIFEST}" | head -1 | cut -d: -f2)"
|
||||
|
||||
echo "Staging: ${STAGING_VERSION}"
|
||||
echo "Producción: ${CURRENT_PROD_VERSION}"
|
||||
|
||||
if [[ "${STAGING_VERSION}" == "${CURRENT_PROD_VERSION}" ]]; then
|
||||
echo "Producción ya está en ${STAGING_VERSION}. Nada que promover."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
read -rp "¿Promover ${STAGING_VERSION} a Producción? [s/N] " CONFIRM
|
||||
[[ "${CONFIRM}" =~ ^[sS]$ ]] || { echo "Cancelado."; exit 1; }
|
||||
|
||||
cd "${APPS_REGISTRY_DIR}"
|
||||
git fetch origin main
|
||||
git checkout -B main origin/main
|
||||
|
||||
sed -i -E "s|(image: ${IMAGE_NAME}:).*|\1${STAGING_VERSION}|g" "${PROD_MANIFEST}"
|
||||
|
||||
git add "${PROD_MANIFEST}"
|
||||
if git diff --cached --quiet; then
|
||||
echo "No hay cambios en el manifiesto de Producción."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
git commit -m "chore: promote ${STAGING_VERSION} to production"
|
||||
git push origin HEAD:main
|
||||
|
||||
echo "Promovido. Argo CD sincroniza ecommerce-app en unos segundos."
|
||||
Reference in new issue
Block a user