-
Notifications
You must be signed in to change notification settings - Fork 7
185 lines (163 loc) · 6.2 KB
/
build-argo-agents.yml
File metadata and controls
185 lines (163 loc) · 6.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
name: Build and Push Argo Agent Containers
on:
push:
branches:
- main
- develop
paths:
- 'examples/argo*/**'
- 'build/**'
- '.github/workflows/build-argo-agents.yml'
pull_request:
branches:
- main
paths:
- 'examples/argo*/**'
- 'build/**'
- '.github/workflows/build-argo-agents.yml'
workflow_dispatch:
inputs:
push_images:
description: 'Push images to registry'
required: false
default: 'true'
type: boolean
env:
REGISTRY: ghcr.io
REGISTRY_NAMESPACE: cnoe-io
jobs:
generate-code:
runs-on: ubuntu-latest
strategy:
matrix:
service:
- name: argo-workflows
make_target: generate-argo-workflows-agent
- name: argocd
make_target: generate-argocd-agent
- name: argo-rollouts
make_target: generate-argo-rollouts-agent
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.13'
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
- name: Generate code for ${{ matrix.service.name }}
run: make ${{ matrix.service.make_target }}
env:
# Add any required environment variables for code generation
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
- name: Upload generated code
uses: actions/upload-artifact@v5
with:
name: generated-code-${{ matrix.service.name }}
path: examples/${{ matrix.service.name }}/generate_code/
retention-days: 1
build-and-push:
needs: generate-code
runs-on: ubuntu-latest
strategy:
matrix:
service:
- name: argo-workflows
image_name: agent-argo-workflows
- name: argocd
image_name: agent-argocd
- name: argo-rollouts
image_name: agent-argo-rollouts
variant:
- mcp
- a2a
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Download generated code
uses: actions/download-artifact@v6
with:
name: generated-code-${{ matrix.service.name }}
path: examples/${{ matrix.service.name }}/generate_code/
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
platforms: linux/amd64,linux/arm64
- name: Log in to Container Registry
if: github.event_name != 'pull_request' && (github.event_name != 'workflow_dispatch' || inputs.push_images)
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.REGISTRY_NAMESPACE }}/${{ matrix.service.image_name }}-${{ matrix.variant }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=sha,prefix={{branch}}-
type=raw,value=autogen-{{date 'YYYYMMDD-HHmmss'}}
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./build/Dockerfile.${{ matrix.variant }}.agent
platforms: linux/amd64,linux/arm64
build-args: |
SERVICE_NAME=${{ matrix.service.name }}
push: ${{ github.event_name != 'pull_request' && (github.event_name != 'workflow_dispatch' || inputs.push_images) }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Generate SARIF report
if: github.event_name != 'pull_request'
uses: aquasecurity/trivy-action@master
with:
image-ref: ${{ env.REGISTRY }}/${{ env.REGISTRY_NAMESPACE }}/${{ matrix.service.image_name }}-${{ matrix.variant }}:latest
format: 'sarif'
output: 'trivy-results-${{ matrix.service.name }}-${{ matrix.variant }}.sarif'
- name: Upload Trivy scan results
if: github.event_name != 'pull_request'
uses: github/codeql-action/upload-sarif@v4
with:
sarif_file: 'trivy-results-${{ matrix.service.name }}-${{ matrix.variant }}.sarif'
summary:
needs: build-and-push
runs-on: ubuntu-latest
if: always()
steps:
- name: Generate build summary
run: |
echo "# 🚀 Argo Agent Container Build Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "## Built Images" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
services=("argo-workflows:agent-argo-workflows" "argocd:agent-argocd" "argo-rollouts:agent-argo-rollouts")
variants=("mcp" "a2a")
for service_pair in "${services[@]}"; do
IFS=':' read -r service_name image_name <<< "$service_pair"
echo "### $service_name" >> $GITHUB_STEP_SUMMARY
for variant in "${variants[@]}"; do
echo "- 📦 \`${{ env.REGISTRY }}/${{ env.REGISTRY_NAMESPACE }}/${image_name}-${variant}:autogen-$(date +%Y%m%d-%H%M%S)\`" >> $GITHUB_STEP_SUMMARY
done
echo "" >> $GITHUB_STEP_SUMMARY
done
echo "## Usage" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Pull and run any of the built images:" >> $GITHUB_STEP_SUMMARY
echo '```bash' >> $GITHUB_STEP_SUMMARY
echo "# MCP Server" >> $GITHUB_STEP_SUMMARY
echo "docker run -p 8000:8000 ${{ env.REGISTRY }}/${{ env.REGISTRY_NAMESPACE }}/agent-argocd-mcp:latest" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "# A2A Agent Server" >> $GITHUB_STEP_SUMMARY
echo "docker run -p 8000:8000 ${{ env.REGISTRY }}/${{ env.REGISTRY_NAMESPACE }}/agent-argocd-a2a:latest" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY