Scan images workflow (kagent-dev/kagent)
The Scan images workflow from kagent-dev/kagent, explained and optimized by Latchkey.
CI health: C - fair
Point runs-on at Latchkey and get run de-duplication, job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the Scan images workflow from the kagent-dev/kagent repository, a real project running GitHub Actions. It is shown here with attribution under its Apache-2.0 license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
name: Scan images
on:
# Trigger once a week on the main branch
schedule:
- cron: '0 0 * * 0' # Every Monday at midnight UTC
# Trigger the workflow on push to the main branch
push:
branches: [ main ]
paths-ignore:
- '**/*.md'
workflow_dispatch:
env:
# Cache key components for better organization
CACHE_KEY_PREFIX: kagent-v2
BRANCH_CACHE_KEY: ${{ github.head_ref || github.ref_name }}
# Consistent builder configuration
BUILDX_BUILDER_NAME: kagent-builder-v0.23.0
BUILDX_VERSION: v0.23.0
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- build_target: controller
image_name: controller
tag_suffix: ""
- build_target: ui
image_name: ui
tag_suffix: ""
- build_target: app
image_name: app
tag_suffix: ""
- build_target: skills-init
image_name: skills-init
tag_suffix: ""
- build_target: golang-adk
image_name: golang-adk
tag_suffix: ""
- build_target: golang-adk-full
image_name: golang-adk
tag_suffix: "-full"
runs-on: ubuntu-latest
services:
registry:
image: registry:2
ports:
- 5001:5000
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
with:
name: ${{ env.BUILDX_BUILDER_NAME }}
version: ${{ env.BUILDX_VERSION }}
platforms: linux/amd64,linux/arm64
use: 'true'
driver-opts: network=host
- name: Set version
id: vars
run: echo "version=v0.0.0-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Print version
run: |
echo "Version: ${{ steps.vars.outputs.version }}"
- name: Run make build
env:
DOCKER_BUILDER: "docker buildx build"
DOCKER_BUILD_ARGS: >-
--cache-from=type=gha
--cache-to=type=gha,mode=max
--build-arg=VERSION=${{ steps.vars.outputs.version }}
--push
run: |
export VERSION=${{ steps.vars.outputs.version }}
make build-${{ matrix.build_target }}
working-directory: ./
- name: Image vulnerability scanner
uses: aquasecurity/trivy-action@v0.36.0
with:
image-ref: localhost:5001/kagent-dev/kagent/${{ matrix.image_name }}:${{ steps.vars.outputs.version }}${{ matrix.tag_suffix }}
severity: 'CRITICAL,HIGH'
ignore-unfixed: true
exit-code: '1'
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: Scan images on: # Trigger once a week on the main branch schedule: - cron: '0 0 * * 0' # Every Monday at midnight UTC # Trigger the workflow on push to the main branch push: branches: [ main ] paths-ignore: - '**/*.md' workflow_dispatch: env: # Cache key components for better organization CACHE_KEY_PREFIX: kagent-v2 BRANCH_CACHE_KEY: ${{ github.head_ref || github.ref_name }} # Consistent builder configuration BUILDX_BUILDER_NAME: kagent-builder-v0.23.0 BUILDX_VERSION: v0.23.0 concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: build: timeout-minutes: 30 strategy: fail-fast: false matrix: include: - build_target: controller image_name: controller tag_suffix: "" - build_target: ui image_name: ui tag_suffix: "" - build_target: app image_name: app tag_suffix: "" - build_target: skills-init image_name: skills-init tag_suffix: "" - build_target: golang-adk image_name: golang-adk tag_suffix: "" - build_target: golang-adk-full image_name: golang-adk tag_suffix: "-full" runs-on: latchkey-small services: registry: image: registry:2 ports: - 5001:5000 steps: - name: Checkout repository uses: actions/checkout@v6 - name: Set up QEMU uses: docker/setup-qemu-action@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v4 with: name: ${{ env.BUILDX_BUILDER_NAME }} version: ${{ env.BUILDX_VERSION }} platforms: linux/amd64,linux/arm64 use: 'true' driver-opts: network=host - name: Set version id: vars run: echo "version=v0.0.0-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT - name: Print version run: | echo "Version: ${{ steps.vars.outputs.version }}" - name: Run make build env: DOCKER_BUILDER: "docker buildx build" DOCKER_BUILD_ARGS: >- --cache-from=type=gha --cache-to=type=gha,mode=max --build-arg=VERSION=${{ steps.vars.outputs.version }} --push run: | export VERSION=${{ steps.vars.outputs.version }} make build-${{ matrix.build_target }} working-directory: ./ - name: Image vulnerability scanner uses: aquasecurity/trivy-action@v0.36.0 with: image-ref: localhost:5001/kagent-dev/kagent/${{ matrix.image_name }}:${{ steps.vars.outputs.version }}${{ matrix.tag_suffix }} severity: 'CRITICAL,HIGH' ignore-unfixed: true exit-code: '1'
What changed
- Run on Latchkey managed runners with one line (
runs-on), which apply the fixes below automatically and self-heal transient failures. This example useslatchkey-small; pick the runner size that fits the job. - Cancel superseded runs when a branch or PR gets a newer push.
- Add a job timeout so a hung step cannot burn hours of runner time.
3 third-party actions are referenced by a movable tag. Pin them to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.
What Latchkey heals here
This workflow has steps that commonly fail on transient issues (network, registries, flaky browsers). On Latchkey managed runners they are detected, retried, and self-healed instead of failing your build:
- Container pulls and builds
This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.