#!/bin/sh
# Illustrative CI gate. This file is NOT executed by Atlas tests.
# Requires kubectl context authorization, immutable reviewed Job/consumer manifests,
# unique Job name per release/attempt, compatible storage mounts and CI timeout policy.
# The Job's pinned image must contain the exact release manifest and publisher.
set -eu

# Before this point, CI validates the complete compatible release set and compares
# the consumer image + versioned paths to the approved R2 manifest. That validation
# is a prerequisite; these kubectl commands do not test application compatibility.
kubectl create -f artifact-preparation-job.yaml
kubectl -n domain-a wait --for=condition=complete job/prepare-r2 --timeout=320s

# Job completion means this image's publish+verify commands succeeded. A timeout,
# Failed Job or context/auth failure stops this script; no consumer is submitted.
kubectl create -f artifact-consumer-pod.yaml

# The consumer Pod is illustrative. A release controller would submit the reviewed
# Deployment then verify rollout/health. Do not repeatedly create an identically
# named Job and mistake a stale Complete result for verification of a new release.
# Retain R1 until promotion, drain and the approved rollback window finish.
