|
24 | 24 | required: true |
25 | 25 | type: string |
26 | 26 | default: "latest" |
| 27 | + |
| 28 | +permissions: |
| 29 | + contents: read |
| 30 | + packages: write |
| 31 | + |
| 32 | +jobs: |
| 33 | + build-and-push-agent: |
| 34 | + timeout-minutes: 10 |
| 35 | + name: Validate Agent Path |
| 36 | + runs-on: ubuntu-latest |
| 37 | + |
| 38 | + steps: |
| 39 | + - name: Checkout repository |
| 40 | + uses: actions/checkout@v4 |
| 41 | + |
| 42 | + - name: Validate agent path exists |
| 43 | + run: | |
| 44 | + if [ ! -d "${{ inputs.agent_path }}" ]; then |
| 45 | + echo "❌ Error: Agent path '${{ inputs.agent_path }}' does not exist" |
| 46 | + exit 1 |
| 47 | + fi |
| 48 | + echo "✅ Agent path verified: ${{ inputs.agent_path }}" |
| 49 | +
|
| 50 | + - name: Validate manifest.yaml exists |
| 51 | + run: | |
| 52 | + if [ ! -f "${{ inputs.agent_path }}/manifest.yaml" ]; then |
| 53 | + echo "❌ Error: manifest.yaml not found in '${{ inputs.agent_path }}'" |
| 54 | + exit 1 |
| 55 | + fi |
| 56 | + echo "✅ manifest.yaml found" |
| 57 | + echo "### Validation Summary" >> $GITHUB_STEP_SUMMARY |
| 58 | + echo "- **Agent Path**: ${{ inputs.agent_path }}" >> $GITHUB_STEP_SUMMARY |
| 59 | + echo "- **Version Tag**: ${{ inputs.version_tag }}" >> $GITHUB_STEP_SUMMARY |
| 60 | + echo "- **Status**: ✅ Validation passed" >> $GITHUB_STEP_SUMMARY |
| 61 | +
|
| 62 | + - name: Set up Docker Buildx |
| 63 | + uses: docker/setup-buildx-action@v3 |
| 64 | + |
| 65 | + - name: Set up Python |
| 66 | + uses: actions/setup-python@v4 |
| 67 | + with: |
| 68 | + python-version: "3.12" |
| 69 | + |
| 70 | + - name: Get latest agentex-sdk version from PyPI |
| 71 | + id: get-version |
| 72 | + run: | |
| 73 | + LATEST_VERSION=$(curl -s https://pypi.org/pypi/agentex-sdk/json | jq -r '.info.version') |
| 74 | + echo "Latest agentex-sdk version: $LATEST_VERSION" |
| 75 | + echo "AGENTEX_SDK_VERSION=$LATEST_VERSION" >> $GITHUB_ENV |
| 76 | + pip install agentex-sdk==$LATEST_VERSION |
| 77 | + echo "Installed agentex-sdk version $LATEST_VERSION" |
| 78 | +
|
| 79 | + - name: Generate Image name |
| 80 | + id: image-name |
| 81 | + run: | |
| 82 | + # Remove examples/tutorials/ prefix and replace / with - |
| 83 | + AGENT_NAME=$(echo "${{ inputs.agent_path }}" | sed 's|^examples/tutorials/||' | sed 's|/|-|g') |
| 84 | + IMAGE_NAME="${AGENT_NAME}-${{ inputs.version_tag }}" |
| 85 | + echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_ENV |
| 86 | + echo "image_name=$IMAGE_NAME" >> $GITHUB_OUTPUT |
| 87 | + echo "Image name set to $IMAGE_NAME" |
| 88 | +
|
| 89 | + - name: Login to GitHub Container Registry |
| 90 | + uses: docker/login-action@v3 |
| 91 | + with: |
| 92 | + registry: ghcr.io |
| 93 | + username: ${{ github.actor }} |
| 94 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 95 | + |
| 96 | + - name: Build and Push Agent Image |
| 97 | + env: |
| 98 | + REGISTRY: ghcr.io |
| 99 | + REPOSITORY: agentex-agents |
| 100 | + run: | |
| 101 | + IMAGE_NAME="${{ steps.image-name.outputs.image_name }}" |
| 102 | +
|
| 103 | + agentex agents build \ |
| 104 | + --manifest "${{ inputs.agent_path }}/manifest.yaml" \ |
| 105 | + --registry "${REGISTRY}" \ |
| 106 | + --tag "${IMAGE_NAME}" \ |
| 107 | + --platforms "linux/amd64" \ |
| 108 | + --repository-name "${REPOSITORY}" \ |
| 109 | + --push |
| 110 | +
|
| 111 | + echo "Successfully built and pushed: ${REGISTRY}/${REPOSITORY}:$IMAGE_NAME" |
| 112 | + echo "### Build Complete" >> $GITHUB_STEP_SUMMARY |
0 commit comments