Search code examples
google-cloud-platformcontinuous-deploymentgoogle-cloud-rungoogle-cloud-build

How to auto deploy latest image from Cloud Build in Cloud Run


My CI/CD pipeline for deploying my Angular app is close, but I see that Google Cloud Run does not deploy a new revision when the container image has been updated.

I have Cloud Build set to trigger a build when a branch on GitHub has been updated. That is working fine and I see I get a new image named after the commit hash. I'm expecting Cloud Run to trigger its service, pick up the latest image and deploy it, but it's not running. I'm not sure if I need to change the image names so they are not unique due to the SHA-1 hash value.


Solution

  • Add a Cloud Build step to deploy the new image to Cloud Run.

    Modify this example with SERVICE_NAME, REGION, PROJECT_ID, and IMAGE.

    # Deploy container image to Cloud Run
    - name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
      entrypoint: gcloud
      args: ['run', 'deploy', 'SERVICE-NAME', '--image', 'gcr.io/PROJECT_ID/IMAGE', '--region', 'REGION', '--platform', 'managed']
    

    Documentation