Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Google Cloud Run Get Project Hash
PROJECT=${1:-"$(gcloud config get-value project)"}
gcloud services enable "" --project="${PROJECT}"
gcloud auth configure-docker --quiet
docker pull nginx
docker tag nginx "${IMAGE}"
docker push "${IMAGE}"
gcloud run deploy \
"hash-temp" \
--project="${PROJECT}" \
--image="${IMAGE}" \
--region="${REGION}" \
--port=80 \
--no-allow-unauthenticated \
--quiet \
SERVICE_INFO=$(gcloud run services describe \
"hash-temp" \
--project="${PROJECT}" \
--region="${REGION}" \
HASH=$(echo ${SERVICE_INFO} | jq -cr '.["status"]["address"]["url"] | match(".*hash\\-temp\\-(.*)\\-.*\\.run\\.app").captures[0].string')
gcloud run services delete \
"hash-temp" \
--project="${PROJECT}" \
--region="${REGION}" \
} &> /dev/null
echo "${HASH}"
Copy link

This 🐌💦 slow script will get you the per-project hash for your Google Cloud Run services.

It simply pulls nginx from docker hub, pushes it to your project container registry, instantiates a Cloud Run service with it, inspects it for the hash, deletes the service and outputs the hash.

See: and give it a +1 if you want a better option!

Copy link

Thanks for the script!

and give it a +1 if you want a better option!

Please do this by clicking the star, not by writing a comment with "+1", everyone who starts the issue gets an email with each new comment.

Screenshot 2022-03-15 at 00 15 11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment