#!/usr/bin/env bash set -euo pipefail root=$(cd -- "$(dirname -- "$0")" && pwd) if [[ ${FACTORIO_CI:-false} != true ]]; then [[ $(kubectl config current-context) == kubernetes-admin@kubernetes ]] || { echo 'Wrong Kubernetes context' >&2; exit 1; } fi work=$(mktemp -d) trap 'rm -rf "$work"' EXIT "$root/render.sh" > "$work/rendered.yaml" python3 "$root/scripts/prepare-deploy.py" "$work/rendered.yaml" > "$work/apply.yaml" kubectl apply --dry-run=server -f "$work/apply.yaml" kubectl apply -f "$work/apply.yaml" if ! kubectl -n factorio rollout status deployment/factorio --timeout=1800s; then kubectl -n factorio get deployment factorio -o yaml kubectl -n factorio get pods -o wide kubectl -n factorio get events --sort-by=.lastTimestamp exit 1 fi