Skip to content

cicd: updated to install uv if not restored from the cache #8

cicd: updated to install uv if not restored from the cache

cicd: updated to install uv if not restored from the cache #8

Workflow file for this run

name: Deploy Agent to AWS
on:
push:
branches:
- main
pull_request:
branches:
- main
types:
- closed
jobs:
setup:
# Only run on push to main or when PR is merged to main
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true)
runs-on: ubuntu-latest
outputs:
agents: ${{ steps.get-agents.outputs.agents }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Extract agent names from config
id: get-agents
run: |
# Extract agent names from YAML using yq
agents=$(yq eval '.agents | keys' .bedrock_agentcore.yaml -o=json -I=0)
echo "agents=$agents" >> "$GITHUB_OUTPUT"
echo "Found agents: $agents"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install uv
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Install dependencies
run: |
uv sync
- name: Cache uv environment
uses: actions/cache/save@v4
with:
path: |
.venv
~/.cargo/bin/uv
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
deploy:
needs: setup
# Loads the secrets from the dev environment from the repository settings
environment: dev
runs-on: ubuntu-latest
strategy:
matrix:
agent: ${{ fromJSON(needs.setup.outputs.agents) }}
fail-fast: false
permissions:
id-token: write
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Restore uv environment
uses: actions/cache/restore@v4
with:
path: |
.venv
~/.cargo/bin/uv
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
- name: Install or restore uv
run: |
if [ ! -f "$HOME/.cargo/bin/uv" ]; then
curl -LsSf https://astral.sh/uv/install.sh | sh
fi
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v5
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: us-east-1
- name: Deploy agent with agentcore
run: |
uv run agentcore launch --agent ${{ matrix.agent }}
cat .bedrock_agentcore.yaml
env:
AWS_DEFAULT_REGION: us-east-1
- name: Upload agent configuration artifact
if: success()
uses: actions/upload-artifact@v4
with:
name: bedrock-agentcore-config-${{ matrix.agent }}-${{ github.sha }}
include-hidden-files: true
path: .bedrock_agentcore.yaml
retention-days: 90
- name: Deployment summary
if: success()
run: |
echo "✅ Agent '${{ matrix.agent }}' deployed successfully to AWS"