Skip to content

Build and Push Tutorial Agent #18

Build and Push Tutorial Agent

Build and Push Tutorial Agent #18

name: Build and Push Tutorial Agent
on:
workflow_dispatch:
inputs:
agent_path:
description: "Path to the agent directory (e.g., examples/tutorials/10_agentic/00_base/000_hello_acp)"
required: true
type: string
version_tag:
description: "Version tag for the agent build (e.g., v1.0.0, latest)"
required: true
type: string
default: "latest"
workflow_call:
inputs:
agent_path:
description: "Path to the agent directory"
required: true
type: string
version_tag:
description: "Version tag for the agent build"
required: true
type: string
default: "latest"
permissions:
contents: read
packages: write
jobs:
build-and-push-agent:
timeout-minutes: 10
name: Build Tutorial Agent
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Validate agent path exists
run: |
if [ ! -d "${{ inputs.agent_path }}" ]; then
echo "❌ Error: Agent path '${{ inputs.agent_path }}' does not exist"
exit 1
fi
echo "✅ Agent path verified: ${{ inputs.agent_path }}"
- name: Validate manifest.yaml exists
run: |
if [ ! -f "${{ inputs.agent_path }}/manifest.yaml" ]; then
echo "❌ Error: manifest.yaml not found in '${{ inputs.agent_path }}'"
exit 1
fi
echo "✅ manifest.yaml found"
echo "### Validation Summary" >> $GITHUB_STEP_SUMMARY
echo "- **Agent Path**: ${{ inputs.agent_path }}" >> $GITHUB_STEP_SUMMARY
echo "- **Version Tag**: ${{ inputs.version_tag }}" >> $GITHUB_STEP_SUMMARY
echo "- **Status**: ✅ Validation passed" >> $GITHUB_STEP_SUMMARY
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.12"
- name: Get latest agentex-sdk version from PyPI
id: get-version
run: |
LATEST_VERSION=$(curl -s https://pypi.org/pypi/agentex-sdk/json | jq -r '.info.version')
echo "Latest agentex-sdk version: $LATEST_VERSION"
echo "AGENTEX_SDK_VERSION=$LATEST_VERSION" >> $GITHUB_ENV
pip install agentex-sdk==$LATEST_VERSION
echo "Installed agentex-sdk version $LATEST_VERSION"
- name: Generate Image name
id: image-name
run: |
# Remove examples/tutorials/ prefix and replace / with -
AGENT_NAME=$(echo "${{ inputs.agent_path }}" | sed 's|^examples/tutorials/||' | sed 's|/|-|g')
echo "AGENT_NAME=$AGENT_NAME" >> $GITHUB_ENV
echo "agent_name=$AGENT_NAME" >> $GITHUB_OUTPUT
echo "Agent name set to $AGENT_NAME"
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push Agent Image
env:
REGISTRY: ghcr.io
run: |
AGENT_NAME="${{ steps.image-name.outputs.agent_name }}"
VERSION_TAG="${{ inputs.version_tag }}"
REPOSITORY_NAME="${{ github.repository }}/tutorial-agents/${AGENT_NAME}"
FULL_IMAGE="${REGISTRY}/${REPOSITORY_NAME}:${VERSION_TAG}"
agentex agents build \
--manifest "${{ inputs.agent_path }}/manifest.yaml" \
--registry "${REGISTRY}" \
--tag "${VERSION_TAG}" \
--platforms "linux/amd64" \
--repository-name "${REPOSITORY_NAME}" \
--push
echo "Successfully built and pushed: ${FULL_IMAGE}"
echo "### Build Complete" >> $GITHUB_STEP_SUMMARY
echo "- **Image**: \`${FULL_IMAGE}\`" >> $GITHUB_STEP_SUMMARY