#!/bin/bash
set -eu
set -o pipefail

# Collect the public key from our podman image, and send it to the Manager.
# We don't rely on knowing our image name.
#
# Instead we iterate over all our images and then the manager
# will check that they *all* have the same key.

images=($( podman container list --format='{{.ImageID}}' | sort -u ))

if [ "${#images[*]}" != 1 ]; then
    echo >&2 "Multiple container images in use: $images"
    exit 8
fi

podman run --network=host "${images[*]}" su builder -c 'gpg --export'	\
 | ssh tag2upload-manager@tag2upload-manager-01.debian.org		\
	keycheck-receive tag2upload-builder
