Files
personal-website/scripts/verify-staging-image.sh
Stan Runge d0c7b6548b
Some checks failed
Test and deploy staging / staging (push) Has been cancelled
beeeeg update
2026-09-23 04:16:50 +00:00

24 lines
841 B
Bash

#!/usr/bin/env bash
set -euo pipefail
sha=${1:?staging commit required}
case "$sha" in
*[!0-9a-f]*|'') echo 'Invalid image tag' >&2; exit 2 ;;
esac
directory=/opt/personal-website-staging
tag=$(sed -n 's/^IMAGE_TAG=//p' "$directory/.env" | head -n 1)
if [ "$tag" != "$sha" ]; then
echo "Staging runs $tag, not $sha" >&2
exit 1
fi
image="git.stanrunge.dev/stan/personal-website:$sha"
container=$(sudo docker compose --env-file "$directory/.env" -f "$directory/compose.prod.yml" ps -q app)
expected=$(sudo docker image inspect -f '{{.Id}}' "$image")
actual=$(sudo docker inspect -f '{{.Image}}' "$container")
if [ "$actual" != "$expected" ]; then
echo 'Staging container differs from the tested image' >&2
exit 1
fi
curl --fail --silent --show-error https://staging.stanrunge.dev/login >/dev/null
echo "Verified staging image $sha"