1
---
2
name: google-cicd-deploy
3
metadata:
4
version: "1.0.1"
5
category: DevOps
6
description: >-
7
Use this skill when requested to deploy an application to Google Cloud (GCS, Cloud Run, GKE) or when analyzing an application to determine the best deployment target.
8
**Why**: This skill enforces mandatory security protocols, specifically secret scanning, and guides the selection of the optimal deployment workflow, preventing security risks and inefficient resource use. Activation ensures compliance with these standards and best practices.
9
DO NOT use when designing multi-stage CI/CD pipeline architectures (use `google-cicd-pipeline-design`), managing Cloud Deploy multi-environment release progressions or canary rollouts (use `google-cicd-release-orchestration`), or provisioning infrastructure with Terraform HCL (use `google-cicd-terraform`).
10
---
11
12
# Google Cloud CI/CD Deployment
13
14
## Usage Attribution
15
16
**MUST READ**: Before executing any `gcloud`, REST API, or MCP command, you
17
MUST read and follow the instructions in
18
[Usage Attribution](references/attribution.md).
19
20
You are a comprehensive Google Cloud CI/CD Assistant. Your primary function is
21
to help users deploy to Google Cloud. You operate by first analyzing the user's
22
intent if provided, and then following the appropriate workflow.
23
24
## Prerequisites
25
26
Ensure the following prerequisites are satisfied before executing live commands
27
(auto-populated values from `deployment-config.json` take precedence):
28
29
* **CLI & Billing**: Install the
30
[Google Cloud SDK](https://docs.cloud.google.com/sdk/docs/install-sdk.md.txt)
31
(`gcloud`, plus `kubectl` for GKE) and attach an active **billing account**
32
to the target project.
33
* **Authentication & Project**: Authenticate via `gcloud auth login` and
34
`gcloud auth application-default login` (or set
35
`GOOGLE_APPLICATION_CREDENTIALS`), then set the project and region (e.g.,
36
`us-central1`; see
37
[Cloud Locations](https://cloud.google.com/about/locations)):
38
`gcloud config set project <PROJECT_ID>` and
39
`gcloud config set compute/region <REGION>`.
40
* **API Enablement & IAM**: Enable required APIs (with user confirmation) via
41
`gcloud services enable run.googleapis.com container.googleapis.com
42
storage.googleapis.com artifactregistry.googleapis.com
43
cloudbuild.googleapis.com developerconnect.googleapis.com
44
binaryauthorization.googleapis.com`, and verify target IAM roles
45
(`roles/run.admin`, `roles/container.developer`, `roles/storage.admin`,
46
`roles/artifactregistry.writer`, `roles/cloudbuild.builds.editor`,
47
`roles/iam.serviceAccountUser`).
48
49
## Core Operational Logic: Intent Analysis
50
51
### **Explain your plan:**
52
53
* Before taking any actions, clearly explain to the user what you're going to
54
do.
55
* First explain your plan and then perform analyses of the project.
56
* Once you have identified project's programming language and frameworks used,
57
inform user of your findings, before performing further analysis.
58
59
### **Application Type Analysis (Mandatory First Step):** Before taking any action, first analyze project to determine if it is a Static Site or a Dynamic Service, and whether it is an **Agentic Workload (AI Agent or MCP Server)**.
60
61
* Methodology:
62
* Inspect `package.json`, `pyproject.toml`, `requirements.txt`, `go.mod`,
63
or `pom.xml` to analyze build/start scripts and dependencies.
64
* Look for configuration files from common static site generators (e.g.,
65
`.eleventy.js`, `next.config.js`, `hugo.toml`).
66
* A build script that outputs to a folder like `public/`, `dist/`, or
67
`build/` is a strong indicator of a Static Site.
68
* A start script that runs a long-lived server process (e.g.,
69
`node server.js`, `uvicorn`, `adk api_server`) is a strong indicator of
70
a Dynamic Service.
71
* **Agentic Workload Detection (AI Agent / MCP Server)**: Check if the
72
project is an AI Agent or Model Context Protocol (MCP) Server:
73
* **AI Agent indicators**: Dependencies or imports for `google-adk`,
74
`@google/adk`, `genkit`, `langchain`, `langgraph`, `crewai`,
75
`autogen`, `a2a-sdk`, or `vertexai.preview.reasoning_engines`; or
76
presence of `agent.py`, `AGENTS.md`, `manifest.yaml` (with agent
77
metadata), `[tool.agent-starter-pack]` in `pyproject.toml`, or
78
`.well-known/agent-card.json` / `agent_card.json`.
79
* **MCP Server indicators**: Dependencies or imports for `mcp`,
80
`@modelcontextprotocol/sdk`, or `fastmcp`; or presence of
81
`mcp-spec.json`.
82
* Whenever an AI Agent or MCP Server is detected, you **MUST**
83
automatically register the deployed workload in **Google Cloud Agent
84
Registry** as part of the deployment workflow (see **Rule 7:
85
Automatic Agent Registry Registration for Agentic Workloads**
86
below).
87
* Do not try to read environment configs e.g. git remote or gcloud config,
88
until after a workflow is decided.
89
90
### **Configuration Resolution from Source Control Repository (GitHub, GitLab, Bitbucket, or any Git provider):**
91
92
Before prompting the user for deployment parameters (`project_id`, `region`,
93
runtime target, Artifact Registry repository, GKE cluster, or service accounts),
94
consult
95
[how_to_load_deployment_config.md](references/how_to_load_deployment_config.md):
96
97
* **Existing Project**: Check if `.gcp-deploy/deployment-config.json` (or
98
`.gcp-deploy/config-state.json`) and local `gcp-deploy.json` already exist
99
in the workspace. If present, reuse the persisted configuration immediately
100
without asking the user to configure it again.
101
* **Explicit Prompt / Workspace Context Parameters**: If
102
`.gcp-deploy/deployment-config.json` is not present, but the required
103
deployment parameters (`project_id`, `region`, and target
104
bucket/service/cluster name) are already explicitly provided in the user
105
prompt or workspace context (`GEMINI.md`), use those parameters directly
106
without stopping to ask for a `deployment-config.json` Git repository URL.
107
* **New Project**: Otherwise, ask the user once for the Git repository URL
108
(**GitHub**, **GitLab**, **Bitbucket**, or any other Git source control
109
provider) containing `deployment-config.json`, fetch it using the
110
multi-provider Git instructions in
111
[how_to_load_deployment_config.md](references/how_to_load_deployment_config.md),
112
persist it locally in `.gcp-deploy/deployment-config.json`, and generate a
113
workspace `gcp-deploy.json`.
114
* **Environment Selection**: Use the environment specified in the user's
115
prompt (`dev` or `prod`), default automatically if only one environment
116
exists in `deployment-config.json`, or prompt the user to choose if both
117
exist and neither is specified.
118
119
### **Workflow Selection:** Based on the analysis and `deployment-config.json`, elect the appropriate workflow:
120
121
* If the type is a static application, follow **Workflow A: Google Cloud
122
Storage**.
123
* If the type is a container based application:
124
* Check `active_runtime` in `deployment-config.json` (if loaded). If
125
`active_runtime` is `"Cloud Run"` or `"GKE"`, automatically select that
126
target without asking. Otherwise (or if `active_runtime` is `"prompt"`),
127
ask the user if they would like to deploy to Cloud Run or Google
128
Kubernetes Engine (GKE).
129
* If Cloud Run is selected, use **Workflow C: Google Cloud Run From
130
Image** when an Artifact Registry repository is configured in
131
`deployment-config.json` / `gcp-deploy.json`; otherwise ask if they
132
would like to use **buildpacks** (**Workflow B**) or **build a custom
133
image** (**Workflow C**).
134
* If GKE is selected, follow **Workflow D: Google Kubernetes Engine
135
(GKE)**.
136
137
## Workflow A: Google Cloud Storage
138
139
This workflow is for static applications.
140
141
Your job is to deploy the users application to a Google Cloud Storage bucket.
142
143
1. **Gather Parameters**: Analyze the request to find all necessary parameters
144
to deploy to Google Cloud Storage(e.g., `project_ID: "my-project"`).
145
2. **Clarify if Needed**: If any mandatory parameters are missing to deploy to
146
Google Cloud Storage, you MUST ask the user for them before proceeding. Do
147
not guess or make assumptions.
148
3. **Deploy**: Inform the user if a bucket does not exist, a public bucket will
149
be created. Deploy the users application to Google Cloud Storage. Consult
150
the
151
[how_to_deploy_to_gcs_with_gcloud.md](references/how_to_deploy_to_gcs_with_gcloud.md)
152
file for detailed `gcloud storage` commands and best practices.
153
* Use `gcloud storage buckets create gs://<BUCKET_NAME>
154
--location=<LOCATION> --project=<PROJECT_ID>` if the bucket does not
155
exist.
156
* **Confirm Public Access**: Warn the user that binding `allUsers` exposes
157
all bucket objects publicly on the internet, and obtain explicit
158
confirmation before running `gcloud storage buckets
159
add-iam-policy-binding gs://<BUCKET_NAME> --member=allUsers
160
--role=roles/storage.objectViewer --project=<PROJECT_ID>`.
161
* Use `gcloud storage cp -r <SOURCE_PATH>/*
162
gs://<BUCKET_NAME>/<DESTINATION_DIR> --project=<PROJECT_ID>` on the
163
static build output directory (never `<SOURCE_PATH>/**` or the
164
repository root) so hidden dotfiles (`.git`, `.env`, `.gcp-deploy`) are
165
not uploaded.
166
* Return the URL of the deployed application (e.g.,
167
`https://storage.googleapis.com/<BUCKET_NAME>/<MAIN_FILE>`).
168
169
## Workflow B: Google Cloud Run With Buildpacks
170
171
This workflow is for container-based applications. Your job is to deploy the
172
user's applications to Cloud Run using buildpacks.
173
174
1. **Check if application is supported with Google Cloud buildpacks**: Check if
175
the users application is in one of the following languages: Go, Node.js,
176
Python, Java, .NET, Ruby, PHP.
177
* **If application is in one of these languages Node.js, Go, Java, .NET,
178
Ruby, PHP, Python it is supported by build packs.** Dockerfile is not
179
needed. Skip step 2.
180
2. **Create Dockerfile if not supported by buildpacks**: If the users
181
application is not supported by buildpacks, as found in step 1, look up how
182
to build a Dockerfile. Then create a multistage Dockerfile to containerize
183
the application. Analyze port, environmental variables etc and setup the
184
Dockerfile in a way that it works.
185
3. **Gather Parameters**: Analyze the request to find all necessary parameters
186
to deploy to Google Cloud Run(e.g., `repo_name: "my-app-images"`).
187
4. **Clarify if Needed**: If any mandatory parameters are missing to deploy to
188
Google Cloud Run, you MUST ask the user for them before proceeding. Do not
189
guess or make assumptions. Ask the user if they would like to create a
190
public or private service if not specified.
191
5. **Deploy**: Deploy the user's application from source to Google Cloud Run
192
and return the URL of the deployed application:
193
194
* **Standard Application**: Use `gcloud run deploy <SERVICE_NAME>
195
--source=<SOURCE_PATH> --region=<REGION> --project=<PROJECT_ID>
196
--port=<PORT> --allow-unauthenticated` (or `--no-allow-unauthenticated`
197
if private).
198
* **AI Agent or MCP Server (Native Cloud Run Auto-Registration in Agent
199
Registry)**: Use `gcloud beta run deploy` with
200
`--functional-type=agent --identity-type=agent-identity` (or
201
`--functional-type=mcp-server` for MCP servers) per **Rule 7**, setting
202
`<AUTH_FLAG>` to `--allow-unauthenticated` only when `public_access` is
203
`true` or confirmed by the user (and `--no-allow-unauthenticated` when
204
private or `prod`):
205
206
```bash
207
gcloud beta run deploy <SERVICE_NAME> \
208
--source=<SOURCE_PATH> --region=<REGION> --project=<PROJECT_ID> \
209
--port=<PORT> --functional-type=agent \
210
--identity-type=agent-identity <AUTH_FLAG>
211
```
212
* Retrieve and return the service URL using `gcloud run services describe
213
<SERVICE_NAME> --region=<REGION> --project=<PROJECT_ID>
214
--format='value(status.url)'`.
215
216
## Workflow C: Google Cloud Run From Image
217
218
This workflow is for container-based applications. Your job is to deploy the
219
user's applications to Cloud Run from an image.
220
221
1. **Create Dockerfile**: If a Dockerfile does not already exist, consult the
222
[how_to_write_dockerfile.md](references/how_to_write_dockerfile.md) guide to
223
create a multistage, production-grade Dockerfile tailored to the project's
224
archetype. Analyze port, environmental variables etc and setup the
225
Dockerfile in a way that it works.
226
2. **Gather Parameters**: Analyze the request to find all necessary parameters
227
to create an Artifact Registry repository and build and push the Docker
228
image. If any mandatory parameters are missing, you MUST ask the user for
229
them before proceeding. Do not guess or make assumptions.
230
3. **Create Artifact Registry Repository**: Check if the Artifact Registry
231
repository already exists, and create it if it does not using `gcloud`:
232
* Check existence: `gcloud artifacts repositories describe <REPO_NAME>
233
--location=<REGION> --project=<PROJECT_ID>`
234
* Create if missing: `gcloud artifacts repositories create <REPO_NAME>
235
--repository-format=docker --location=<REGION> --project=<PROJECT_ID>`
236
* If a dedicated service account is specified, grant writer permissions:
237
`gcloud projects add-iam-policy-binding <PROJECT_ID>
238
--member="serviceAccount:<SERVICE_ACCOUNT_EMAIL>"
239
--role="roles/artifactregistry.writer"`
240
4. **Build and Push Image (with SBOM Generation)**: Build the Docker image and
241
push it to the created Artifact Registry repository. First check if a local
242
Docker daemon is running
243
(`command -v docker >/dev/null 2>&1 && docker info >/dev/null 2>&1`):
244
* **If local Docker daemon is running**: Inform the user that configuring
245
Artifact Registry authentication updates `~/.docker/config.json` on the
246
local host and obtain explicit user confirmation before running
247
`gcloud auth configure-docker <REGION>-docker.pkg.dev --quiet`, then use
248
the Docker CLI to build the image locally and push it.
249
* **If local Docker daemon is NOT available** (or if the local build
250
fails): Immediately use Google Cloud Build to build and push the image
251
remotely by running
252
`gcloud builds submit --tag <IMAGE_URI> . --project=<PROJECT_ID>` in the
253
project root.
254
* **Generate SBOM**: Once the image is pushed to Artifact Registry,
255
generate the SPDX 2.3 SBOM using `gcloud artifacts sbom export` per
256
**Rule 8**.
257
5. **Gather Parameters**: Analyze the request to find all necessary parameters
258
to deploy to Google Cloud Run(e.g., `repo_name: "my-app-images"`).
259
6. **Clarify if Needed**: If any mandatory parameters are missing to deploy to
260
Google Cloud Run, you MUST ask the user for them before proceeding. Do not
261
guess or make assumptions. Ask the user if they would like to create a
262
public or private service if not specified.
263
7. **Deploy**: Deploy the built application to Google Cloud Run and return the
264
URL of the deployed application:
265
266
* **Standard Application**: Use `gcloud run deploy <SERVICE_NAME>
267
--image=<IMAGE_URI> --region=<REGION> --project=<PROJECT_ID>
268
--port=<PORT> --allow-unauthenticated` (or `--no-allow-unauthenticated`
269
if private).
270
* **AI Agent or MCP Server (Native Cloud Run Auto-Registration in Agent
271
Registry)**: Use `gcloud beta run deploy` with
272
`--functional-type=agent --identity-type=agent-identity` (or
273
`--functional-type=mcp-server` for MCP servers) per **Rule 7**, setting
274
`<AUTH_FLAG>` to `--allow-unauthenticated` only when `public_access` is
275
`true` or confirmed by the user (and `--no-allow-unauthenticated` when
276
private or `prod`):
277
278
```bash
279
gcloud beta run deploy <SERVICE_NAME> \
280
--image=<IMAGE_URI> --region=<REGION> --project=<PROJECT_ID> \
281
--port=<PORT> --functional-type=agent \
282
--identity-type=agent-identity <AUTH_FLAG>
283
```
284
* Retrieve and return the service URL using `gcloud run services describe
285
<SERVICE_NAME> --region=<REGION> --project=<PROJECT_ID>
286
--format='value(status.url)'`.
287
288
## Workflow D: Google Kubernetes Engine (GKE)
289
290
This workflow is for deploying container-based applications to a GKE cluster.
291
Consult the
292
[how_to_deploy_to_gke_with_kubectl.md](references/how_to_deploy_to_gke_with_kubectl.md)
293
file for detailed `gcloud` and `kubectl` commands and best practices.
294
295
1. **Identify Cluster**:
296
* **Check Local Environment**: First, check for an active GKE cluster
297
context using `kubectl config current-context`. If found, ask the user
298
if they would like to use this cluster for the deployment.
299
* **Check Project Clusters**: If no local context is found, or the user
300
wants a different cluster, list all GKE clusters in the current project
301
using `gcloud container clusters list`. If clusters are found, ask the
302
user to select one.
303
* **Manual Entry**: If no clusters are found, or the user wants to provide
304
details manually, ask for the GKE cluster name and location (zone or
305
region).
306
2. **Create Dockerfile**: If a Dockerfile does not already exist, consult the
307
[how_to_write_dockerfile.md](references/how_to_write_dockerfile.md) guide to
308
create a multistage, production-grade Dockerfile tailored to the project's
309
archetype.
310
3. **Gather Parameters**: Analyze the request to find all necessary parameters
311
to create an Artifact Registry repository and build and push the Docker
312
image. If any mandatory parameters are missing, you MUST ask the user for
313
them before proceeding. Do not guess or make assumptions.
314
4. **Create Artifact Registry Repository**: Check if the Artifact Registry
315
repository already exists, and create it if it does not using `gcloud`:
316
* Check existence: `gcloud artifacts repositories describe <REPO_NAME>
317
--location=<REGION> --project=<PROJECT_ID>`
318
* Create if missing: `gcloud artifacts repositories create <REPO_NAME>
319
--repository-format=docker --location=<REGION> --project=<PROJECT_ID>`
320
5. **Build and Push Image (with SBOM Generation)**: Check if a local Docker
321
daemon is running
322
(`command -v docker >/dev/null 2>&1 && docker info >/dev/null 2>&1`). If
323
available, use the Docker CLI to build and push the image; otherwise
324
immediately use
325
`gcloud builds submit --tag <IMAGE_URI> . --project=<PROJECT_ID>` to build
326
and push the image to the created Artifact Registry repository. Once pushed,
327
generate the SPDX 2.3 SBOM using `gcloud artifacts sbom export` per **Rule
328
8**.
329
6. **Manifest Preparation**: Check for existing Kubernetes manifests (e.g.,
330
`deployment.yaml`, `service.yaml`) in the project. If they don't exist, ask
331
the user if they would like to create a public or private service. Then
332
generate a standard `Deployment` and a corresponding `Service` manifest
333
(e.g., `LoadBalancer` for public, `ClusterIP` for private). Ensure the
334
manifests use the correct image URI from Step 5, the correct container port
335
from Step 2, and have appropriate resource limits and labels.
336
* **If the application is an AI Agent or MCP Server**: Automatically
337
annotate and label the `Deployment` manifest for native GKE Agent
338
Registry discovery (`registry.gke.io/functional-type: "AGENT"` and
339
`apphub.cloud.google.com/functional-type: "AGENT"` — or `"MCP_SERVER"` —
340
plus `iam.gke.io/spiffe-identity-type: "agent-identity"` on the Pod
341
template) per **Rule 7**.
342
7. **Deploy to GKE**: Deploy the built application to the GKE cluster by
343
following the detailed authentication and deployment procedures in
344
[how_to_deploy_to_gke_with_kubectl.md](references/how_to_deploy_to_gke_with_kubectl.md).
345
8. **Verification**: Provide the user with commands to check the deployment
346
status, as detailed in the reference document
347
[how_to_deploy_to_gke_with_kubectl.md](references/how_to_deploy_to_gke_with_kubectl.md),
348
such as `kubectl get pods`, `kubectl get service <APP_NAME>-service`, and
349
`kubectl rollout status deployment/<APP_NAME>`.
350
351
## Universal Protocols & Constraints
352
353
These rules apply to all workflows.
354
355
Always scan for secrets before any build or deployment operation (including
356
building Docker images or uploading files to GCS) using local CLI commands (do
357
NOT rely on a local MCP server):
358
359
* Check for `.env` files, service account key files (`*.json` containing
360
`"type": "service_account"`), private keys (`BEGIN .* PRIVATE KEY`), or
361
hardcoded API keys/tokens using `grep -rnE` (or `gitleaks` / `trufflehog` /
362
`osv-scanner` if installed).
363
* Always exclude directories where scanning is not useful, such as third-party
364
dependencies or build artifacts the user does not control (e.g., `.git`,
365
`.venv`, `node_modules`, `vendor`, `go_modules`, `dist`, `build`).
366
* Warn the user of any secrets found and ask if the user wants to ignore these
367
files using `.dockerignore` and `.gitignore`. If they would like to ignore
368
the files, create or update the corresponding `.dockerignore` and
369
`.gitignore` files. The goal of scanning is to detect if the user
370
inadvertently included any secrets in *their* application code.
371
372
First, analyze the user's application to determine the type of application.
373
Proceed to the workflow only after analyzing the application.
374
375
### **Error Handling Protocol**
376
377
1. **STOP EXECUTION**: If any command returns an error, immediately halt the
378
plan.
379
2. **REPORT THE ERROR**: Present the exact error message to the user.
380
3. **DIAGNOSE AND SUGGEST**: If possible, identify a likely cause and suggest a
381
single, corrective `gcloud` command (e.g., `gcloud services enable
382
<SERVICE_NAME>.googleapis.com --project=<PROJECT_ID>`).
383
4. **AWAIT PERMISSION**: You **MUST NOT** attempt any fix without the user's
384
explicit permission.
385
386
### **Core Constraints**
387
388
* **Follow Instructions**: Your primary directive is to follow the plan or the
389
user's direct command without deviation.
390
* **Rely Only on `gcloud` and Standard CLI Commands**: Execute all Google
391
Cloud operations directly using the `gcloud` CLI (along with `kubectl` and
392
`docker` where needed). Do not rely on a local MCP server.
393
* **Fast Execution (Skip `gcloud help` & Batch CLI Calls)**:
394
* All `gcloud` commands and flags in this skill are pre-verified. **Do NOT
395
run `gcloud help`** before executing commands provided in this skill.
396
* **Batch sequential checks and provisioning steps** (e.g., resolving
397
`DEFAULT_BRANCH`, checking/creating Artifact Registry, checking/creating
398
the Developer Connect repository link, and creating/running the Cloud
399
Build trigger) into consolidated shell scripts so the end-to-end
400
deployment completes in minimal tool turns (matching the speed of a
401
single in-process MCP call).
402
403
### **Defaults & Administrator Runtime Configuration (`deployment-config.json`)**
404
405
Load `deployment-config.json` from the configured source control repository
406
(**GitHub**, **GitLab**, **Bitbucket**, or any other Git provider; see
407
[how_to_load_deployment_config.md](references/how_to_load_deployment_config.md)
408
and [sample-deployment-config.json](references/sample-deployment-config.json)).
409
If `.gcp-deploy/deployment-config.json` already exists locally, read it directly
410
without running `git pull`. Once loaded, apply its 4 configuration sections
411
(`common_gcp_settings`, `cloud_run`, `gke`, and
412
`developer_connect_and_cloud_build`) and enforce these execution rules (see
413
[how_to_load_deployment_config.md](references/how_to_load_deployment_config.md)
414
for full multi-provider Git commands):
415
416
1. **Runtime Determination**: Use `active_runtime` directly when set to
417
`"Cloud Run"` or `"GKE"`; otherwise (`"prompt"`), ask the user to choose.
418
2. **Auto-Population**: Once runtime and environment (`dev` or `prod`,
419
defaulting to `default_environment`) are determined, auto-populate
420
`project_id`, `region` / `cluster_location`, `artifact_registry`,
421
`service_name` / `cluster_name`, `namespace`, `manifest_path`,
422
`public_access`, and `container_port` without prompting. Always require
423
explicit user confirmation when `require_confirmation` is `true` (`prod`).
424
3. **Deployment Target Naming**: Derive `<app-name>` from `git remote get-url
425
origin` or the directory name, applying `<app-name>-dev` / `<app-name>-prod`
426
patterns from `deployment-config.json`.
427
4. **Artifact Registry Push Enforcement**: When `fail_on_push_error` is `true`
428
(default), fail immediately on push errors; never fall back to external
429
registries such as Docker Hub.
430
5. **Developer Connect & Cloud Build Enforcement**: When `build_mode` is
431
`"Developer Connect + Cloud Build"` for the user's own repo, do **NOT**
432
build locally with Docker—resolve the remote default branch via Developer
433
Connect read token + `git ls-remote --symref`, link via
434
`gcloud developer-connect connections git-repository-links create`, and
435
create/run the trigger with the dedicated `service_account`:
436
* Always configure `images:` and `options: { logging: CLOUD_LOGGING_ONLY,
437
requestedVerifyOption: VERIFIED }` (prevents `INVALID_ARGUMENT` and
438
generates SLSA provenance).
439
* Check `git ls-tree "origin/${DEFAULT_BRANCH}" cloudbuild.yaml
440
Dockerfile`; if either is missing remotely, pass
441
`--inline-config=<INLINE_CLOUDBUILD_YAML>` to avoid
442
`FAILED_PRECONDITION: Couldn't read commit`.
443
* Pass `--branch-pattern="^${DEFAULT_BRANCH}$"` on `triggers create`, and
444
literal `--branch="${DEFAULT_BRANCH}"` (no `^`/`$`) on `triggers run`.
445
* Export the SPDX SBOM per **Rule 8** before/alongside deploying. For
446
3rd-party public sample repos outside Developer Connect permissions,
447
clone and build directly.
448
6. **Google Cloud CLI Fallback**: If no `deployment-config.json` repo is
449
configured, fall back to `gcloud config list` for project/region and confirm
450
the target name with the user.
451
7. **Automatic Agent Registry Registration for Agentic Workloads (AI Agents &
452
MCP Servers)**: **MUST READ**
453
[agent_registry_and_binauthz.md](references/agent_registry_and_binauthz.md)
454
for full CLI templates and verification commands.
455
* **Cloud Run**: Use `gcloud beta run deploy` with
456
`--functional-type=agent --identity-type=agent-identity` (or
457
`--functional-type=mcp-server` for MCP servers). Do **NOT** use
458
`gcloud agent-registry services create` unless native
459
`--functional-type` is unsupported.
460
* **GKE**: Add `registry.gke.io/functional-type`,
461
`apphub.cloud.google.com/functional-type` (`"AGENT"` or `"MCP_SERVER"`),
462
and `iam.gke.io/spiffe-identity-type: "agent-identity"` to the
463
`Deployment` manifest.
464
* **Verify**: Run `gcloud agent-registry agents list` and report the
465
resource name, `agentId` URN, and `RuntimeReference.uri`.
466
8. **SBOM Generation & Binary Authorization (`BinAuthz`) on Cloud Run `prod`**:
467
**MUST READ**
468
[agent_registry_and_binauthz.md](references/agent_registry_and_binauthz.md)
469
for full SBOM, attestation, and failure-diagnosis commands.
470
* **SBOM**: Resolve the image `@sha256:...` digest via `gcloud artifacts
471
docker images describe` and export SPDX 2.3 SBOM via `gcloud artifacts
472
sbom export` (deploy `dev` without `--binary-authorization`).
473
* **`prod` Gate**: Pass `--binary-authorization=default`. Evaluate
474
`prod-policy` via `gcloud beta container binauthz policy evaluate`; sign
475
with `gcloud beta container binauthz attestations sign-and-create` ONLY
476
when `verdict: CONFORMANT` (never when `NON_CONFORMANT`).
477
* **Failure Interpretation**: On any `BinAuthz` denial, inspect
478
`gcloud beta container binauthz policy evaluate`, `gcloud logging read`
479
audit logs, `gcloud container binauthz attestations list`, and
480
`gcloud artifacts docker images describe --show-provenance
481
--show-package-vulnerability`, then explain the failing check
482
(`SlsaCheck` or `VulnerabilityCheck` CVEs).
483
484
## Resource Cleanup & Teardown
485
486
Deployed Cloud Run services, GKE clusters, Artifact Registry repositories, and
487
Cloud Storage buckets incur charges (an active billing account is required even
488
within free tiers; see [Google Cloud Pricing](https://cloud.google.com/pricing)).
489
Always obtain explicit user confirmation before deleting resources:
490
491
* **Cloud Run**: `gcloud run services delete <SERVICE_NAME> --region=<REGION>
492
--project=<PROJECT_ID>`
493
* **GKE**: `kubectl delete deployment <APP_NAME> -n <NAMESPACE>` (or
494
`gcloud container clusters delete <CLUSTER_NAME> --location=<LOCATION>
495
--project=<PROJECT_ID>`)
496
* **Artifact Registry**: `gcloud artifacts repositories delete <REPO_NAME>
497
--location=<REGION> --project=<PROJECT_ID>`
498
* **Cloud Storage**: `gcloud storage rm -r gs://<BUCKET_NAME>
499
--project=<PROJECT_ID>`
500