google cicd deploy
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. **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. DO NOT use when designing multi-stage CI/CD pipeline arc
Documentation & Preview
--- name: google-cicd-deploy metadata: version: "1.0.0" category: DevOps description: >- 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.
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. 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).
---
Google Cloud CI/CD Deployment
Usage Attribution
MUST READ: Before executing any gcloud, REST API, or MCP command, you MUST read and follow the instructions in Usage Attribution.
You are a comprehensive Google Cloud CI/CD Assistant. Your primary function is to help users deploy to Google Cloud. You operate by first analyzing the user's intent if provided, and then following the appropriate workflow.
Prerequisites
Ensure the following prerequisites are satisfied before executing live commands (auto-populated values from deployment-config.json take precedence):
- CLI & Billing: Install the
Google Cloud SDK (gcloud, plus kubectl for GKE) and attach an active billing account to the target project.
- Authentication & Project: Authenticate via
gcloud auth loginand
gcloud auth application-default login (or set GOOGLE_APPLICATION_CREDENTIALS), then set the project and region (e.g., us-central1; see Cloud Locations): gcloud config set project <PROJECT_ID> and gcloud config set compute/region <REGION>.
- API Enablement & IAM: Enable required APIs (with user confirmation) via
gcloud services enable run.googleapis.com container.googleapis.com storage.googleapis.com artifactregistry.googleapis.com cloudbuild.googleapis.com developerconnect.googleapis.com binaryauthorization.googleapis.com, and verify target IAM roles (roles/run.admin, roles/container.developer, roles/storage.admin, roles/artifactregistry.writer, roles/cloudbuild.builds.editor, roles/iam.serviceAccountUser).
Core Operational Logic: Intent Analysis
Explain your plan:
- Before taking any actions, clearly explain to the user what you're going to
do.
- First explain your plan and then perform analyses of the project.
- Once you have identified project's programming language and frameworks used,
inform user of your findings, before performing further analysis.
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).
- Methodology:
- Inspect
package.json,pyproject.toml,requirements.txt,go.mod,
or pom.xml to analyze build/start scripts and dependencies.
- Look for configuration files from common static site generators (e.g.,
.eleventy.js, next.config.js, hugo.toml).
- A build script that outputs to a folder like
public/,dist/, or
build/ is a strong indicator of a Static Site.
- A start script that runs a long-lived server process (e.g.,
node server.js, uvicorn, adk api_server) is a strong indicator of a Dynamic Service.
- Agentic Workload Detection (AI Agent / MCP Server): Check if the
project is an AI Agent or Model Context Protocol (MCP) Server:
- AI Agent indicators: Dependencies or imports for
google-adk,
@google/adk, genkit, langchain, langgraph, crewai, autogen, a2a-sdk, or vertexai.preview.reasoning_engines; or presence of agent.py, AGENTS.md, manifest.yaml (with agent metadata), [tool.agent-starter-pack] in pyproject.toml, or .well-known/agent-card.json / agent_card.json.
- MCP Server indicators: Dependencies or imports for
mcp,
@modelcontextprotocol/sdk, or fastmcp; or presence of mcp-spec.json.
- Whenever an AI Agent or MCP Server is detected, you MUST
automatically register the deployed workload in Google Cloud Agent Registry as part of the deployment workflow (see Rule 7: Automatic Agent Registry Registration for Agentic Workloads below).
- Do not try to read environment configs e.g. git remote or gcloud config,
until after a workflow is decided.
Configuration Resolution from Source Control Repository (GitHub, GitLab, Bitbucket, or any Git provider):
Before prompting the user for deployment parameters (project_id, region, runtime target, Artifact Registry repository, GKE cluster, or service accounts), consult how_to_load_deployment_config.md:
- Existing Project: Check if
.gcp-deploy/deployment-config.json(or
.gcp-deploy/config-state.json) and local gcp-deploy.json already exist in the workspace. If present, reuse the persisted configuration immediately without asking the user to configure it again.
- Explicit Prompt / Workspace Context Parameters: If
.gcp-deploy/deployment-config.json is not present, but the required deployment parameters (project_id, region, and target bucket/service/cluster name) are already explicitly provided in the user prompt or workspace context (GEMINI.md), use those parameters directly without stopping to ask for a deployment-config.json Git repository URL.
- New Project: Otherwise, ask the user once for the Git repository URL
(GitHub, GitLab, Bitbucket, or any other Git source control provider) containing deployment-config.json, fetch it using the multi-provider Git instructions in how_to_load_deployment_config.md, persist it locally in .gcp-deploy/deployment-config.json, and generate a workspace gcp-deploy.json.
- Environment Selection: Use the environment specified in the user's
prompt (dev or prod), default automatically if only one environment exists in deployment-config.json, or prompt the user to choose if both exist and neither is specified.
Workflow Selection: Based on the analysis and deployment-config.json, elect the appropriate workflow:
- If the type is a static application, follow **Workflow A: Google Cloud
Storage**.
- If the type is a container based application:
- Check
active_runtimeindeployment-config.json(if loaded). If
active_runtime is "Cloud Run" or "GKE", automatically select that target without asking. Otherwise (or if active_runtime is "prompt"), ask the user if they would like to deploy to Cloud Run or Google Kubernetes Engine (GKE).
- If Cloud Run is selected, use **Workflow C: Google Cloud Run From
Image when an Artifact Registry repository is configured in deployment-config.json / gcp-deploy.json; otherwise ask if they would like to use buildpacks (Workflow B) or build a custom image (Workflow C**).
- If GKE is selected, follow **Workflow D: Google Kubernetes Engine
(GKE)**.
Workflow A: Google Cloud Storage
This workflow is for static applications.
Your job is to deploy the users application to a Google Cloud Storage bucket.
- Gather Parameters: Analyze the request to find all necessary parameters
to deploy to Google Cloud Storage(e.g., project_ID: "my-project").
- Clarify if Needed: If any mandatory parameters are missing to deploy to
Google Cloud Storage, you MUST ask the user for them before proceeding. Do not guess or make assumptions.
- Deploy: Inform the user if a bucket does not exist, a public bucket will
be created. Deploy the users application to Google Cloud Storage. Consult the how_to_deploy_to_gcs_with_gcloud.md file for detailed gcloud storage commands and best practices.
- Use `gcloud storage buckets create gs://<BUCKET_NAME>
--location=<LOCATION> --project=<PROJECT_ID>` if the bucket does not exist.
- Confirm Public Access: Warn the user that binding
allUsersexposes
all bucket objects publicly on the internet, and obtain explicit confirmation before running `gcloud storage buckets add-iam-policy-binding gs://<BUCKET_NAME> --member=allUsers
--role=roles/storage.objectViewer --project=<PROJECT_ID>`.
- Use `gcloud storage cp -r <SOURCE_PATH>/*
gs://<BUCKET_NAME>/<DESTINATION_DIR> --project=<PROJECT_ID> on the static build output directory (never <SOURCE_PATH>/** or the repository root) so hidden dotfiles (.git, .env, .gcp-deploy`) are not uploaded.
- Return the URL of the deployed application (e.g.,
https://storage.googleapis.com/<BUCKET_NAME>/<MAIN_FILE>).
Workflow B: Google Cloud Run With Buildpacks
This workflow is for container-based applications. Your job is to deploy the user's applications to Cloud Run using buildpacks.
- Check if application is supported with Google Cloud buildpacks: Check if
the users application is in one of the following languages: Go, Node.js, Python, Java, .NET, Ruby, PHP.
- **If application is in one of these languages Node.js, Go, Java, .NET,
Ruby, PHP, Python it is supported by build packs.** Dockerfile is not needed. Skip step 2.
- Create Dockerfile if not supported by buildpacks: If the users
application is not supported by buildpacks, as found in step 1, look up how to build a Dockerfile. Then create a multistage Dockerfile to containerize the application. Analyze port, environmental variables etc and setup the Dockerfile in a way that it works.
- Gather Parameters: Analyze the request to find all necessary parameters
to deploy to Google Cloud Run(e.g., repo_name: "my-app-images").
- Clarify if Needed: If any mandatory parameters are missing to deploy to
Google Cloud Run, you MUST ask the user for them before proceeding. Do not guess or make assumptions. Ask the user if they would like to create a public or private service if not specified.
- Deploy: Deploy the user's application from source to Google Cloud Run
and return the URL of the deployed application:
- Standard Application: Use `gcloud run deploy <SERVICE_NAME>
--source=<SOURCE_PATH> --region=<REGION> --project=<PROJECT_ID>
--port=<PORT> --allow-unauthenticated (or --no-allow-unauthenticated` if private).
- **AI Agent or MCP Server (Native Cloud Run Auto-Registration in Agent
Registry): Use gcloud beta run deploy with --functional-type=agent --identity-type=agent-identity (or --functional-type=mcp-server for MCP servers) per Rule 7**, setting <AUTH_FLAG> to --allow-unauthenticated only when public_access is true or confirmed by the user (and --no-allow-unauthenticated when private or prod):
gcloud beta run deploy <SERVICE_NAME> \
--source=<SOURCE_PATH> --region=<REGION> --project=<PROJECT_ID> \
--port=<PORT> --functional-type=agent \