|
28 | 28 | permissions: |
29 | 29 | contents: read |
30 | 30 | packages: write |
31 | | - |
32 | | -jobs: |
33 | | - build-and-push-agent: |
34 | | - timeout-minutes: 10 |
35 | | - name: Build Tutorial Agent |
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 | | - echo "AGENT_NAME=$AGENT_NAME" >> $GITHUB_ENV |
85 | | - echo "agent_name=$AGENT_NAME" >> $GITHUB_OUTPUT |
86 | | - echo "Agent name set to $AGENT_NAME" |
87 | | -
|
88 | | - - name: Login to GitHub Container Registry |
89 | | - uses: docker/login-action@v3 |
90 | | - with: |
91 | | - registry: ghcr.io |
92 | | - username: ${{ github.actor }} |
93 | | - password: ${{ secrets.GITHUB_TOKEN }} |
94 | | - |
95 | | - - name: Build and Push Agent Image |
96 | | - env: |
97 | | - REGISTRY: ghcr.io |
98 | | - run: | |
99 | | - AGENT_NAME="${{ steps.image-name.outputs.agent_name }}" |
100 | | - VERSION_TAG="${{ inputs.version_tag }}" |
101 | | - REPOSITORY_NAME="${{ github.repository }}/tutorial-agents/${AGENT_NAME}" |
102 | | - FULL_IMAGE="${REGISTRY}/${REPOSITORY_NAME}:${VERSION_TAG}" |
103 | | -
|
104 | | - agentex agents build \ |
105 | | - --manifest "${{ inputs.agent_path }}/manifest.yaml" \ |
106 | | - --registry "${REGISTRY}" \ |
107 | | - --tag "${VERSION_TAG}" \ |
108 | | - --platforms "linux/amd64" \ |
109 | | - --repository-name "${REPOSITORY_NAME}" \ |
110 | | - --push |
111 | | -
|
112 | | - echo "Successfully built and pushed: ${FULL_IMAGE}" |
113 | | - echo "### Build Complete" >> $GITHUB_STEP_SUMMARY |
114 | | - echo "- **Image**: \`${FULL_IMAGE}\`" >> $GITHUB_STEP_SUMMARY |
0 commit comments