Lessons in this course (9)

8. CI/CD — Cloud Build, Artifact Registry, Cloud Deploy and GitHub Actions

IntermediateMediumLesson 8 of 9
yaml
# cloudbuild.yaml — build, push and deploy on every commit (trigger from GitHub)
steps:
  - name: gcr.io/cloud-builders/docker
    args: ["build", "-t", "asia-south1-docker.pkg.dev/$PROJECT_ID/shop/api:$SHORT_SHA", "."]
  - name: gcr.io/cloud-builders/docker
    args: ["push", "asia-south1-docker.pkg.dev/$PROJECT_ID/shop/api:$SHORT_SHA"]
  - name: gcr.io/google.com/cloudsdktool/cloud-sdk
    entrypoint: gcloud
    args: ["run", "deploy", "shop-api", "--image", "asia-south1-docker.pkg.dev/$PROJECT_ID/shop/api:$SHORT_SHA", "--region", "asia-south1"]
images: ["asia-south1-docker.pkg.dev/$PROJECT_ID/shop/api:$SHORT_SHA"]

GitHub Actions alternative: google-github-actions/auth with Workload Identity Federation (no JSON keys) + google-github-actions/deploy-cloudrun. Cloud Deploy manages promotion pipelines (dev → staging → prod) for GKE and Cloud Run with approvals and rollbacks.