Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

feat(ci): deploy AI Gateway automatically to staging (#17532)

Hassieb Pakzadcbd45e6c5578
diff --git a/.agents/skills/git-workflow/SKILL.md b/.agents/skills/git-workflow/SKILL.md
index efa0fb667c..9cd444402d 100644
--- a/.agents/skills/git-workflow/SKILL.md
+++ b/.agents/skills/git-workflow/SKILL.md
@@ -94,5 +94,8 @@ operations.
or the GitHub "Latest release" badge. At the next major GA (v5), repeat
the flip: move the gate to `refs/tags/v5` on `main`, then disable it and
set `makeLatest: false` on the new `v4` maintenance branch.
+- The ECS deployment workflow includes `ai-gateway` only for staging: pushes
+ to `main` and manual staging deployments. Its image builds from `ai-gateway/`
+ with `BUILD_ID` set to the commit SHA; production deployments exclude it.
- Do not change release/versioning flow without updating this skill and the
impacted package guides.
diff --git a/.github/workflows/_deploy_ecs_service.yml b/.github/workflows/_deploy_ecs_service.yml
index c995a50d72..1bbd3efd16 100644
--- a/.github/workflows/_deploy_ecs_service.yml
+++ b/.github/workflows/_deploy_ecs_service.yml
@@ -8,7 +8,7 @@ on:
required: true
service:
type: string
- description: Name of the service to be deployed, e.g. web-ingestion, web, or worker.
+ description: Name of the service to be deployed, e.g. web-ingestion, web, worker, or ai-gateway.
required: true
# Environment secrets don't auto-resolve in reusable workflows.
# See: https://github.com/actions/runner/issues/3206
@@ -21,6 +21,7 @@ on:
required: false
jobs:
ecs-deploy:
+ if: ${{ inputs.service != 'ai-gateway' || inputs.environment == 'staging' }}
runs-on: blacksmith-4vcpu-ubuntu-2404
environment: ${{ inputs.environment }}
permissions:
@@ -47,7 +48,21 @@ jobs:
- name: Login to AWS ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@d539f0932e70871a027e9d5a9d8fc38589180a64 # v2.1.6
+ - name: Build, tag, and push AI Gateway image
+ if: ${{ inputs.service == 'ai-gateway' }}
+ env:
+ REGISTRY: ${{ steps.login-ecr.outputs.registry }}
+ IMAGE_TAG: ${{ github.sha }}
+ run: |
+ docker build \
+ --platform linux/amd64 \
+ --target runtime \
+ --build-arg BUILD_ID="$IMAGE_TAG" \
+ -t "$REGISTRY/ai-gateway:$IMAGE_TAG" \
+ ./ai-gateway
+ docker push "$REGISTRY/ai-gateway:$IMAGE_TAG"
- name: Build, tag, and push Docker image
+ if: ${{ inputs.service != 'ai-gateway' }}
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REPOSITORY: ${{ steps.split.outputs._0 }}
@@ -93,7 +108,7 @@ jobs:
uses: aws-actions/amazon-ecs-render-task-definition@138c24f321fdbdf7edee4a685519d253cae2cdea # v1.9.0
with:
container-name: ${{ inputs.service }}
- image: ${{ steps.login-ecr.outputs.registry }}/${{ steps.split.outputs._0 }}:${{ github.sha }}
+ image: ${{ steps.login-ecr.outputs.registry }}/${{ inputs.service == 'ai-gateway' && 'ai-gateway' || steps.split.outputs._0 }}:${{ github.sha }}
task-definition-family: ${{ inputs.environment }}-${{ inputs.service }}
- name: Update AWS ECS Service
uses: aws-actions/amazon-ecs-deploy-task-definition@c465972ecbd160473f22e683363b422a5412a3de # v2.6.3
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
index 22abd93895..b58d9a9271 100644
--- a/.github/workflows/deploy.yml
+++ b/.github/workflows/deploy.yml
@@ -15,6 +15,7 @@ on:
- web-iso
- worker
- worker-cpu
+ - ai-gateway
required: true
environment:
description: "Environment to deploy to"
@@ -46,14 +47,21 @@ jobs:
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
+ const services = ["web", "web-ingestion", "web-iso", "worker", "worker-cpu"];
+ const isStaging = context.eventName === "workflow_dispatch"
+ ? context.payload.inputs.environment === "staging"
+ : context.ref === "refs/heads/main";
+ if (isStaging) services.push("ai-gateway");
+
if (context.eventName === "workflow_dispatch") {
- if (context.payload.inputs.service === "all") {
- return `["web", "web-ingestion", "web-iso", "worker", "worker-cpu"]`
+ const service = context.payload.inputs.service;
+ if (service === "ai-gateway" && !isStaging) {
+ throw new Error("AI Gateway deployments are only enabled in staging.");
}
- return `["${context.payload.inputs.service}"]`
+ return JSON.stringify(service === "all" ? services : [service]);
}
if (context.eventName === "push") {
- return `["web", "web-ingestion", "web-iso", "worker", "worker-cpu"]`
+ return JSON.stringify(services);
}
return "[]"
result-encoding: string