#!/usr/bin/env bash
# Build the ecd-runner image, pinning the latest actions/runner release.
set -euo pipefail
cd "$(dirname "$0")"

RUNNER_VERSION="${RUNNER_VERSION:-}"
if [[ -z "${RUNNER_VERSION}" ]]; then
  RUNNER_VERSION="$(curl -fsSL https://api.github.com/repos/actions/runner/releases/latest \
    | jq -r '.tag_name' | sed 's/^v//')"
fi
echo "Building ecd-runner:latest with actions/runner v${RUNNER_VERSION}"

docker build \
  --build-arg "RUNNER_VERSION=${RUNNER_VERSION}" \
  -t ecd-runner:latest \
  .
echo "Done."
