Skip to content
Latchkey

gcloud run deploy: Ship to Cloud Run in CI

Deploy a container image or source directory to a Cloud Run service.

gcloud run deploy creates or updates a Cloud Run service from a prebuilt image or directly from source. In CI you typically build and push an image first, then deploy it by digest or tag. Flags control region, auth, scaling, and environment.

Common flags

  • SERVICE - the service name (positional)
  • --image=IMAGE - container image to deploy
  • --region=REGION - required unless run/region is configured
  • --allow-unauthenticated - make the service public
  • --set-env-vars=KEY=VALUE - set environment variables

Example in CI

Deploy an image built earlier in the pipeline.

shell
gcloud run deploy api \
  --image=us-central1-docker.pkg.dev/my-project/repo/api:${GITHUB_SHA} \
  --region=us-central1 \
  --platform=managed \
  --quiet

Common errors in CI

  • Revision is not ready and cannot serve traffic - container failed to start or did not listen on $PORT
  • PERMISSION_DENIED: ... run.services.create - SA missing roles/run.admin
  • Image not found - wrong digest/tag or the push step did not complete

Key takeaways

  • Deploys an image or source to Cloud Run and shifts traffic to the new revision.
  • Always pass --region (or configure it) and --quiet for non-interactive runs.
  • Most failures are a container that does not listen on $PORT or a missing run.admin role.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →