#!/bin/bash

set -eux

PROJECT_ID=$(gcloud config get-value project)
gcloud builds submit --tag gcr.io/$PROJECT_ID/gnis --timeout 15m
gcloud run deploy --platform managed gnis --image gcr.io/$PROJECT_ID/gnis --memory 1024Mi

gcloud container images list-tags gcr.io/$PROJECT_ID/gnis --format=json | jq -rc '.[]|select(.tags==[]).digest' | while read DIGEST
do
  gcloud container images delete gcr.io/$PROJECT_ID/gnis@$DIGEST
done

# vi: ts=2 sw=2 et

