fix(ci): build-gate skip-graceful si HARBOR_ROBOT_* ausente (GOLDEN-PATH-BUILD-DEPLOY-ORDER-RACE)
E2E 2026-06-05 mostró que en template mínimo la calidad corre ~15s, así que el build alcanza 'Build y push a Harbor' antes de que tenant-manager fase 1 siembre (~20s) → run #1 rojo. build-gate (1er job) skipea el build si HARBOR_ROBOT_USER ausente, simétrico al cluster-gate. El dispatch de fase 2 hace el run completo. Sync desde coralware/IDP. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -17,9 +17,39 @@ on:
|
|||||||
workflow_dispatch: {}
|
workflow_dispatch: {}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
# ── Gate de credenciales de build (GOLDEN-PATH-BUILD-DEPLOY-ORDER-RACE) ───
|
||||||
|
# Los secrets HARBOR_ROBOT_USER/TOKEN los siembra tenant-manager en su fase 1
|
||||||
|
# (build-ready) cuando RepoProvision.phase=ready. El commit de render de
|
||||||
|
# repo-provisioner dispara este workflow on:push en segundos; en un template
|
||||||
|
# mínimo la calidad (ruff/black/bandit/pytest) corre en ~15s, así que el build
|
||||||
|
# alcanzaría el step "Build y push a Harbor" ANTES de que la fase 1 siembre
|
||||||
|
# (~20s) → fallaría con secrets vacíos. Este gate decide ANTES de la calidad:
|
||||||
|
# si los secrets no están, el job build se SKIPEA (no falla, no rojo) y
|
||||||
|
# tenant-manager dispara automáticamente un run completo (workflow_dispatch)
|
||||||
|
# tras la fase 1+2. Simétrico con cluster-gate del helm-deploy.
|
||||||
|
build-gate:
|
||||||
|
name: ¿Credenciales de build listas?
|
||||||
|
runs-on: [self-hosted, buildkit]
|
||||||
|
outputs:
|
||||||
|
ready: ${{ steps.check.outputs.ready }}
|
||||||
|
steps:
|
||||||
|
- name: Verificar secrets Harbor sembrados
|
||||||
|
id: check
|
||||||
|
env:
|
||||||
|
ROBOT_USER: ${{ secrets.HARBOR_ROBOT_USER }}
|
||||||
|
run: |
|
||||||
|
if [ -z "$ROBOT_USER" ]; then
|
||||||
|
echo "::notice::Credenciales Harbor aún no sembradas (tenant-manager fase 1 build-ready). Este run se omite; el deploy completo se dispara automáticamente cuando estén listas (run #2)."
|
||||||
|
echo "ready=false" >> "$GITHUB_OUTPUT"
|
||||||
|
else
|
||||||
|
echo "ready=true" >> "$GITHUB_OUTPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
# ── Calidad + build + push de imagen a Harbor ────────────────────────────
|
# ── Calidad + build + push de imagen a Harbor ────────────────────────────
|
||||||
build:
|
build:
|
||||||
name: Calidad + build + push
|
name: Calidad + build + push
|
||||||
|
needs: build-gate
|
||||||
|
if: needs.build-gate.outputs.ready == 'true'
|
||||||
runs-on: [self-hosted, buildkit]
|
runs-on: [self-hosted, buildkit]
|
||||||
outputs:
|
outputs:
|
||||||
image_tag: ${{ steps.meta.outputs.tag }}
|
image_tag: ${{ steps.meta.outputs.tag }}
|
||||||
@@ -57,8 +87,9 @@ jobs:
|
|||||||
|
|
||||||
- name: Build y push a Harbor
|
- name: Build y push a Harbor
|
||||||
# Proyecto Harbor del tenant: `t-<tenant-id-short>` (ADR-019 D-03).
|
# Proyecto Harbor del tenant: `t-<tenant-id-short>` (ADR-019 D-03).
|
||||||
# Credenciales: robot scoped push/pull SOLO a ese proyecto, sembrado
|
# Credenciales: robot scoped push/pull SOLO a ese proyecto, sembrado por
|
||||||
# por tenant-manager en el repo del tenant (paso 3 del reconcile).
|
# tenant-manager (fase 1 build-ready). El job build-gate ya garantizó que
|
||||||
|
# HARBOR_ROBOT_USER está presente (si no, este job se habría skipeado).
|
||||||
env:
|
env:
|
||||||
REGISTRY: registry.coralsafety.com
|
REGISTRY: registry.coralsafety.com
|
||||||
ROBOT_USER: ${{ secrets.HARBOR_ROBOT_USER }}
|
ROBOT_USER: ${{ secrets.HARBOR_ROBOT_USER }}
|
||||||
@@ -66,11 +97,6 @@ jobs:
|
|||||||
IMAGE: t-__TENANT_ID_SHORT__/__APP_NAME__
|
IMAGE: t-__TENANT_ID_SHORT__/__APP_NAME__
|
||||||
TAG: ${{ steps.meta.outputs.tag }}
|
TAG: ${{ steps.meta.outputs.tag }}
|
||||||
run: |
|
run: |
|
||||||
if [ -z "$ROBOT_USER" ] || [ -z "$ROBOT_TOKEN" ]; then
|
|
||||||
echo "ERROR: secrets HARBOR_ROBOT_USER/HARBOR_ROBOT_TOKEN no configurados."
|
|
||||||
echo "tenant-manager debe sembrarlos al crear el repo (paso 3 del reconcile)."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
printf '%s' "$ROBOT_TOKEN" | docker login "$REGISTRY" -u "$ROBOT_USER" --password-stdin
|
printf '%s' "$ROBOT_TOKEN" | docker login "$REGISTRY" -u "$ROBOT_USER" --password-stdin
|
||||||
# Builder buildx remoto — apunta al buildkit daemon de ci-system
|
# Builder buildx remoto — apunta al buildkit daemon de ci-system
|
||||||
# (el runner no tiene Docker daemon local).
|
# (el runner no tiene Docker daemon local).
|
||||||
|
|||||||
Reference in New Issue
Block a user