|
| 1 | +# Build Configuration to be used when a PR is opened or updated. |
| 2 | +steps: |
| 3 | + # Build the EV Finder API container image |
| 4 | + - name: "gcr.io/cloud-builders/docker" |
| 5 | + args: |
| 6 | + [ |
| 7 | + "build", |
| 8 | + "-t", |
| 9 | + "us-central1-docker.pkg.dev/${PROJECT_ID}/evfinder-api/evfinder-api:${TAG_NAME}", |
| 10 | + ".", |
| 11 | + ] |
| 12 | + |
| 13 | + # Push to Artifact Registry |
| 14 | + - name: "gcr.io/cloud-builders/docker" |
| 15 | + args: |
| 16 | + [ |
| 17 | + "push", |
| 18 | + "us-central1-docker.pkg.dev/${PROJECT_ID}/evfinder-api/evfinder-api:${TAG_NAME}", |
| 19 | + ] |
| 20 | + id: "docker push" |
| 21 | + |
| 22 | + # Build and Deploy the API to Cloud Run |
| 23 | + - name: google/cloud-sdk |
| 24 | + args: |
| 25 | + [ |
| 26 | + "gcloud", |
| 27 | + "run", |
| 28 | + "deploy", |
| 29 | + "api", |
| 30 | + "--image", |
| 31 | + "us-central1-docker.pkg.dev/${PROJECT_ID}/evfinder-api/evfinder-api:${TAG_NAME}", |
| 32 | + "--set-env-vars", |
| 33 | + "VERSION=${TAG_NAME}", |
| 34 | + "--region", |
| 35 | + "us-central1", |
| 36 | + "--platform", |
| 37 | + "managed", |
| 38 | + "--execution-environment", |
| 39 | + "gen1", |
| 40 | + "--cpu-boost", |
| 41 | + "--memory", |
| 42 | + "512Mi", |
| 43 | + "--use-http2", |
| 44 | + "--allow-unauthenticated", |
| 45 | + "--tag", |
| 46 | + "canary", |
| 47 | + "--no-traffic", |
| 48 | + ] |
| 49 | + id: "deploy main api" |
| 50 | + waitFor: |
| 51 | + - "docker push" |
| 52 | + |
| 53 | + # Build and deploy the Ford API |
| 54 | + - name: google/cloud-sdk |
| 55 | + args: |
| 56 | + [ |
| 57 | + "gcloud", |
| 58 | + "run", |
| 59 | + "deploy", |
| 60 | + "ford-api", |
| 61 | + "--image", |
| 62 | + "us-central1-docker.pkg.dev/${PROJECT_ID}/evfinder-api/evfinder-api:${TAG_NAME}", |
| 63 | + "--set-env-vars", |
| 64 | + "VERSION=${TAG_NAME}", |
| 65 | + "--region", |
| 66 | + "us-central1", |
| 67 | + "--platform", |
| 68 | + "managed", |
| 69 | + "--execution-environment", |
| 70 | + "gen1", |
| 71 | + "--cpu-boost", |
| 72 | + "--memory", |
| 73 | + "512Mi", |
| 74 | + "--use-http2", |
| 75 | + "--allow-unauthenticated", |
| 76 | + "--tag", |
| 77 | + "canary", |
| 78 | + "--no-traffic", |
| 79 | + ] |
| 80 | + id: "deploy ford api" |
| 81 | + waitFor: |
| 82 | + - "docker push" |
| 83 | + |
| 84 | + # Swing traffic over to the newly deploy API |
| 85 | + - name: google/cloud-sdk |
| 86 | + args: |
| 87 | + [ |
| 88 | + "gcloud", |
| 89 | + "run", |
| 90 | + "services", |
| 91 | + "update-traffic", |
| 92 | + "api", |
| 93 | + "--to-tags", |
| 94 | + "canary=50", |
| 95 | + "--region", |
| 96 | + "us-central1", |
| 97 | + ] |
| 98 | + waitFor: |
| 99 | + - "deploy main api" |
| 100 | + |
| 101 | + # Swing traffic over to the newly deploy Ford API |
| 102 | + - name: google/cloud-sdk |
| 103 | + args: |
| 104 | + [ |
| 105 | + "gcloud", |
| 106 | + "run", |
| 107 | + "services", |
| 108 | + "update-traffic", |
| 109 | + "ford-api", |
| 110 | + "--to-tags", |
| 111 | + "canary=50", |
| 112 | + "--region", |
| 113 | + "us-central1", |
| 114 | + ] |
| 115 | + waitFor: |
| 116 | + - "deploy ford api" |
| 117 | + |
| 118 | +images: |
| 119 | + - "us-central1-docker.pkg.dev/evfinder/evfinder-api/evfinder-api:${TAG_NAME}" |
| 120 | + |
| 121 | +options: |
| 122 | + logging: CLOUD_LOGGING_ONLY |
0 commit comments