Files
feedc0de 9d0e7f5c95
Validate and deploy asciinema / Validate manifests (push) Successful in 13s
Validate and deploy asciinema / Deploy to Kubernetes (push) Successful in 36s
First try in deploying asciinema to kubernetes
2026-09-11 09:10:24 +02:00

60 lines
2.0 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
project_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
bash -n "${project_dir}/install.sh"
bash -n "${project_dir}/create-ci-kubeconfig.sh"
bash -n "${project_dir}/test.sh"
image=$(sed -n 's|^[[:space:]]*image: \(ghcr.io/asciinema/asciinema-server[^[:space:]]*\)$|\1|p' \
"${project_dir}/asciinema.yaml")
if [[ -z "${image}" || "${image}" == *:latest || "${image}" != *@sha256:* ]]; then
echo "The asciinema server image must use a non-latest tag pinned by digest." >&2
exit 1
fi
postgres_image=$(sed -n 's|^[[:space:]]*image: \(postgres:[^[:space:]]*\)$|\1|p' \
"${project_dir}/infrastructure.yaml")
if [[ -z "${postgres_image}" || "${postgres_image}" == *:latest || "${postgres_image}" != *@sha256:* ]]; then
echo "The PostgreSQL image must use a non-latest tag pinned by digest." >&2
exit 1
fi
if ! grep -Fq 'storageClassName: rook-ceph-block-ec' "${project_dir}/infrastructure.yaml"; then
echo "The dedicated PostgreSQL claim must use retained Ceph block storage." >&2
exit 1
fi
if grep -Eqi 'redis|valkey' \
"${project_dir}/asciinema.yaml" "${project_dir}/bootstrap.yaml"; then
echo "asciinema should not use Redis/Valkey." >&2
exit 1
fi
validate_file() {
local manifest=$1
shift
if command -v kubeconform >/dev/null 2>&1; then
kubeconform -strict -summary "$@" "${manifest}"
elif command -v docker >/dev/null 2>&1; then
docker run --rm --interactive \
ghcr.io/yannh/kubeconform:v0.7.0@sha256:85dbef6b4b312b99133decc9c6fc9495e9fc5f92293d4ff3b7e1b30f5611823c \
-strict -summary "$@" < "${manifest}"
else
echo "Required command not found: install kubeconform or Docker" >&2
exit 1
fi
}
validate_file "${project_dir}/asciinema.yaml"
validate_file "${project_dir}/bootstrap.yaml"
validate_file "${project_dir}/infrastructure.yaml"
validate_file "${project_dir}/namespace.yaml"
validate_file "${project_dir}/ceph-object-user.yaml" -ignore-missing-schemas
validate_file "${project_dir}/ci-deployer.yaml"
echo "asciinema scripts and Kubernetes resources are valid for ${image}."