Skip to content

fix(.dockerignore): include all rag sources #756

fix(.dockerignore): include all rag sources

fix(.dockerignore): include all rag sources #756

name: Agent A2A Docker Build and Push
on:
push:
branches:
- main
# Build on all new tags as well
tags:
- '**'
pull_request:
branches:
- main
paths:
- 'ai_platform_engineering/utils/**'
- 'ai_platform_engineering/agents/**'
workflow_dispatch:
inputs:
build_all:
description: 'Build all containers (skip change detection)'
required: false
default: false
type: boolean
env:
ALL_AGENTS: '["argocd","aws","backstage","confluence","github","jira","komodor","pagerduty","slack","splunk","template","webex","weather"]'
jobs:
set-all-agents:
runs-on: ubuntu-latest
if: always()
outputs:
all_agents: ${{ steps.set-agents.outputs.all_agents }}
steps:
- name: Set all agents list
id: set-agents
run: echo "all_agents=${{ env.ALL_AGENTS }}" >> $GITHUB_OUTPUT
determine-agents:
runs-on: ubuntu-latest
if: |
((github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')))) ||
(github.event_name == 'pull_request' && !startsWith(github.head_ref, 'prebuild/')) ||
(github.event_name == 'workflow_dispatch')
outputs:
agents: ${{ steps.set-matrix.outputs.agents }}
should_build: ${{ steps.set-matrix.outputs.should_build }}
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Generate path filters
id: generate-filters
uses: actions/github-script@v8
with:
script: |
const agents = JSON.parse(process.env.ALL_AGENTS);
let filters = 'shared:\n';
filters += ' - \'ai_platform_engineering/utils/a2a/a2a_remote_agent_connect.py\'\n';
filters += ' - \'ai_platform_engineering/utils/agntcy/agntcy_remote_agent_connect.py\'\n';
agents.forEach(agent => {
filters += `${agent}:\n`;
filters += ` - 'ai_platform_engineering/agents/${agent}/**'\n`;
filters += ` - '!ai_platform_engineering/agents/${agent}/mcp/**'\n`;
filters += ` - '!ai_platform_engineering/agents/${agent}/build/Dockerfile.mcp'\n`;
});
core.setOutput('filters', filters);
- name: Detect changed paths
id: filter
uses: dorny/paths-filter@v3
with:
filters: ${{ steps.generate-filters.outputs.filters }}
- name: Set matrix based on changes
id: set-matrix
uses: actions/github-script@v8
env:
BUILD_ALL: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
CHANGED_ARGOCD: ${{ steps.filter.outputs.argocd }}
CHANGED_AWS: ${{ steps.filter.outputs.aws }}
CHANGED_BACKSTAGE: ${{ steps.filter.outputs.backstage }}
CHANGED_CONFLUENCE: ${{ steps.filter.outputs.confluence }}
CHANGED_GITHUB: ${{ steps.filter.outputs.github }}
CHANGED_JIRA: ${{ steps.filter.outputs.jira }}
CHANGED_KOMODOR: ${{ steps.filter.outputs.komodor }}
CHANGED_PAGERDUTY: ${{ steps.filter.outputs.pagerduty }}
CHANGED_SLACK: ${{ steps.filter.outputs.slack }}
CHANGED_SPLUNK: ${{ steps.filter.outputs.splunk }}
CHANGED_TEMPLATE: ${{ steps.filter.outputs.template }}
CHANGED_WEBEX: ${{ steps.filter.outputs.webex }}
CHANGED_WEATHER: ${{ steps.filter.outputs.weather }}
CHANGED_LITELLM: ${{ steps.filter.outputs.litellm }}
with:
script: |
const allAgents = JSON.parse(process.env.ALL_AGENTS);
const buildAll = process.env.BUILD_ALL === 'true';
let selected;
if (buildAll) {
selected = allAgents;
} else {
const env = process.env;
selected = allAgents.filter(a => env['CHANGED_' + a.toUpperCase()] === 'true');
}
core.setOutput('agents', JSON.stringify(selected));
core.setOutput('should_build', String(selected.length > 0));
build-and-push:
runs-on: ubuntu-latest
needs: [determine-agents, set-all-agents]
if: (needs.determine-agents.outputs.should_build == 'true' && (github.event_name != 'pull_request' || !startsWith(github.head_ref, 'prebuild/')))
permissions:
contents: read
packages: write
strategy:
matrix:
agent: ${{ fromJson(needs.determine-agents.outputs.agents) }}
fail-fast: false
env:
REGISTRY: ghcr.io
IMAGE_NAME: cnoe-io/agent-${{ matrix.agent }}
AGENT_DIR: ai_platform_engineering/agents/${{ matrix.agent }}
steps:
- name: 🔒 harden runner
uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
with:
egress-policy: audit
- name: Checkout repository
uses: actions/checkout@v5
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
type=ref,event=branch,prefix=
type=ref,event=tag,prefix=
type=sha,format=short,prefix=
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Build and Push A2A Docker image
uses: docker/build-push-action@v6
with:
context: ${{ env.AGENT_DIR }}
file: ${{ env.AGENT_DIR }}/build/Dockerfile.a2a
push: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max