Skip to content

Ignore agents directory in book build workflow #4

Ignore agents directory in book build workflow

Ignore agents directory in book build workflow #4

Workflow file for this run

name: Deploy Edmund Agent
on:
push:
branches: [ main ]
paths:
- 'agents/edmund/**'
pull_request:
branches: [ main ]
paths:
- 'agents/edmund/**'
workflow_dispatch:
env:
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
AZURE_RESOURCE_GROUP: copilot-edmund
AZURE_LOCATION: eastus
AGENT_NAME: edmund-engineer
AI_FOUNDRY_PROJECT: edmund-tminus15-project
AZURE_OPENAI_ENDPOINT: "https://copilot-edmund.openai.azure.com/"
AZURE_OPENAI_API_VERSION: "2024-12-01-preview"
AZURE_OPENAI_DEPLOYMENT_NAME: "gpt-4o"
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install jsonschema pyyaml
- name: Validate agent configuration
run: |
python -c "
import json
import yaml
# Validate agent-config.json
with open('agents/edmund/agent-config.json', 'r') as f:
config = json.load(f)
print('✓ agent-config.json is valid JSON')
# Validate deployment.yaml
with open('agents/edmund/deployment.yaml', 'r') as f:
deployment = yaml.safe_load_all(f)
for doc in deployment:
if doc:
print('✓ deployment.yaml document is valid YAML')
# Check required fields
required_fields = ['agent', 'model', 'instructions']
for field in required_fields:
if field not in config:
raise ValueError(f'Missing required field: {field}')
print('✓ All configuration files are valid')
"
- name: Test configuration syntax
run: |
cd agents/edmund
python -m json.tool agent-config.json > /dev/null
echo "✓ agent-config.json syntax is valid"
deploy-dev:
runs-on: ubuntu-latest
needs: validate
if: github.ref == 'refs/heads/main'
environment: DEMO
steps:
- uses: actions/checkout@v4
- name: Azure Login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Set up Azure CLI extensions
run: |
az extension add --name ml --version 2.22.0 --yes
az extension add --name ai-examples --yes
az version
- name: Verify Azure subscription and resource group
run: |
echo "Checking Azure subscription..."
az account show --output table
echo "Checking resource group..."
az group show --name $AZURE_RESOURCE_GROUP --output table || {
echo "Creating resource group $AZURE_RESOURCE_GROUP..."
az group create --name $AZURE_RESOURCE_GROUP --location $AZURE_LOCATION
}
- name: Create or update AI Foundry project
run: |
echo "Setting up AI Foundry project..."
# Check if project exists
if ! az ml workspace show --name $AI_FOUNDRY_PROJECT --resource-group $AZURE_RESOURCE_GROUP >/dev/null 2>&1; then
echo "Creating new AI Foundry project..."
az ml workspace create \
--name $AI_FOUNDRY_PROJECT \
--resource-group $AZURE_RESOURCE_GROUP \
--location $AZURE_LOCATION \
--display-name "Edmund T-Minus-15 Agent Project" \
--description "AI Foundry project for Edmund, the Engineering Agent from T-Minus-15 methodology"
else
echo "AI Foundry project already exists"
fi
- name: Configure workspace connection
run: |
echo "Configuring AI Foundry workspace connection..."
az configure --defaults group=$AZURE_RESOURCE_GROUP workspace=$AI_FOUNDRY_PROJECT
- name: Deploy agent configuration
run: |
cd agents/edmund
echo "Preparing agent deployment..."
# Create a deployment package
mkdir -p deployment-package
cp agent-config.json deployment-package/
cp deployment.yaml deployment-package/
cp knowledge-sources.json deployment-package/ 2>/dev/null || echo "knowledge-sources.json not found, skipping"
echo "Agent configuration prepared for deployment"
# Deploy using Azure OpenAI integration (skip model deployment as it already exists)
echo "Configuring Edmund agent with existing Azure OpenAI deployment..."
# Create endpoint first
az ml online-endpoint create \
--name $AGENT_NAME-endpoint \
--resource-group $AZURE_RESOURCE_GROUP \
--workspace-name $AI_FOUNDRY_PROJECT \
--auth-mode key || echo "Endpoint may already exist"
# Create a simple deployment configuration without model path
cat > simple-deployment.yaml << EOF
name: $AGENT_NAME-$(date +%Y%m%d-%H%M%S)
endpoint_name: $AGENT_NAME-endpoint
code_configuration:
code: .
scoring_script: scoring.py
environment:
conda_file: conda.yaml
image: mcr.microsoft.com/azureml/openmpi4.1.0-ubuntu20.04:latest
instance_type: Standard_DS3_v2
instance_count: 1
app_insights_enabled: true
request_settings:
request_timeout_ms: 90000
max_concurrent_requests_per_instance: 1
max_queue_wait_ms: 500
environment_variables:
AZURE_OPENAI_ENDPOINT: "${{ env.AZURE_OPENAI_ENDPOINT }}"
AZURE_OPENAI_API_KEY: \${{ secrets.AZURE_OPENAI_API_KEY }}
AZURE_OPENAI_API_VERSION: "${{ env.AZURE_OPENAI_API_VERSION }}"
AZURE_OPENAI_DEPLOYMENT_NAME: "${{ env.AZURE_OPENAI_DEPLOYMENT_NAME }}"
AGENT_CONFIG_PATH: "./agent-config.json"
LOG_LEVEL: "INFO"
DEPLOYMENT_ENVIRONMENT: "production"
EOF

Check failure on line 175 in .github/workflows/deploy-edmund.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/deploy-edmund.yml

Invalid workflow file

You have an error in your yaml syntax on line 175
# Deploy using the simplified configuration
az ml online-deployment create \
--file simple-deployment.yaml \
--endpoint-name $AGENT_NAME-endpoint \
--resource-group $AZURE_RESOURCE_GROUP \
--workspace-name $AI_FOUNDRY_PROJECT
- name: Test deployment
run: |
echo "Testing agent deployment..."
# Wait for deployment to be ready
sleep 30
# Test agent endpoint
az ml online-endpoint invoke \
--name $AGENT_NAME-endpoint \
--resource-group $AZURE_RESOURCE_GROUP \
--workspace-name $AI_FOUNDRY_PROJECT \
--request-file - <<EOF || echo "Deployment test completed (may need additional configuration)"
{
"messages": [
{
"role": "user",
"content": "Hello Edmund, can you help me with a quick engineering question?"
}
]
}
EOF
- name: Update traffic allocation
run: |
echo "Setting traffic allocation to latest deployment..."
# Get the latest deployment name
LATEST_DEPLOYMENT=$(az ml online-deployment list \
--endpoint-name $AGENT_NAME-endpoint \
--resource-group $AZURE_RESOURCE_GROUP \
--workspace-name $AI_FOUNDRY_PROJECT \
--query "[0].name" -o tsv)
if [ ! -z "$LATEST_DEPLOYMENT" ]; then
az ml online-endpoint update \
--name $AGENT_NAME-endpoint \
--resource-group $AZURE_RESOURCE_GROUP \
--workspace-name $AI_FOUNDRY_PROJECT \
--traffic "$LATEST_DEPLOYMENT=100"
echo "Traffic allocated to deployment: $LATEST_DEPLOYMENT"
fi
- name: Output deployment information
run: |
echo "=== Deployment Summary ==="
echo "Agent Name: $AGENT_NAME"
echo "Resource Group: $AZURE_RESOURCE_GROUP"
echo "AI Foundry Project: $AI_FOUNDRY_PROJECT"
echo "Location: $AZURE_LOCATION"
# Get endpoint details
az ml online-endpoint show \
--name $AGENT_NAME-endpoint \
--resource-group $AZURE_RESOURCE_GROUP \
--workspace-name $AI_FOUNDRY_PROJECT \
--output table || echo "Could not retrieve endpoint details"
echo "=== Deployment Complete ==="
cleanup-old-deployments:
runs-on: ubuntu-latest
needs: deploy-dev
if: github.ref == 'refs/heads/main'
steps:
- name: Azure Login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Clean up old deployments
run: |
echo "Cleaning up old deployments (keeping latest 3)..."
# Get all deployments for the endpoint
DEPLOYMENTS=$(az ml online-deployment list \
--endpoint-name $AGENT_NAME-endpoint \
--resource-group $AZURE_RESOURCE_GROUP \
--workspace-name $AI_FOUNDRY_PROJECT \
--query "[].name" -o tsv | sort -r)
# Keep only the latest 3, delete the rest
echo "$DEPLOYMENTS" | tail -n +4 | while read deployment; do
if [ ! -z "$deployment" ]; then
echo "Deleting old deployment: $deployment"
az ml online-deployment delete \
--name $deployment \
--endpoint-name $AGENT_NAME-endpoint \
--resource-group $AZURE_RESOURCE_GROUP \
--workspace-name $AI_FOUNDRY_PROJECT \
--yes --no-wait || echo "Could not delete deployment: $deployment"
fi
done