Build AgentGateway image #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Copyright 2026 Google LLC | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| # See the License for the specific language governing permissions and | |
| # limitations under the License. | |
| name: Build AgentGateway image | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| repository: | |
| description: AgentGateway repository | |
| required: true | |
| default: agentgateway/agentgateway | |
| sha: | |
| description: AgentGateway commit SHA | |
| required: true | |
| permissions: | |
| contents: read | |
| packages: write | |
| jobs: | |
| source: | |
| runs-on: ubuntu-24.04 | |
| outputs: | |
| sha: ${{ steps.source.outputs.sha }} | |
| short_sha: ${{ steps.source.outputs.short_sha }} | |
| steps: | |
| - name: Checkout AgentGateway | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: ${{ inputs.repository }} | |
| ref: ${{ inputs.sha }} | |
| persist-credentials: false | |
| - name: Resolve source revision | |
| id: source | |
| run: | | |
| echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" | |
| echo "short_sha=$(git rev-parse --short=12 HEAD)" >> "$GITHUB_OUTPUT" | |
| build: | |
| needs: source | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - platform: linux/amd64 | |
| runner: ubuntu-24.04 | |
| artifact: linux-amd64 | |
| - platform: linux/arm64 | |
| runner: ubuntu-24.04-arm | |
| artifact: linux-arm64 | |
| runs-on: ${{ matrix.runner }} | |
| steps: | |
| - name: Checkout AgentGateway | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: ${{ inputs.repository }} | |
| ref: ${{ needs.source.outputs.sha }} | |
| persist-credentials: false | |
| - name: Log in to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build and push by digest | |
| id: build | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| platforms: ${{ matrix.platform }} | |
| tags: ghcr.io/${{ github.repository }}/agentgateway | |
| outputs: type=image,push-by-digest=true,name-canonical=true,push=true | |
| build-args: | | |
| VERSION=0.0.0-alpha.${{ needs.source.outputs.short_sha }} | |
| GIT_REVISION=${{ needs.source.outputs.sha }} | |
| - name: Export digest | |
| run: | | |
| mkdir -p "$RUNNER_TEMP/digests" | |
| digest='${{ steps.build.outputs.digest }}' | |
| touch "$RUNNER_TEMP/digests/${digest#sha256:}" | |
| - name: Upload digest | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: digest-${{ matrix.artifact }} | |
| path: ${{ runner.temp }}/digests/* | |
| if-no-files-found: error | |
| retention-days: 1 | |
| push: | |
| needs: | |
| - source | |
| - build | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Download digests | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: ${{ runner.temp }}/digests | |
| pattern: digest-linux-* | |
| merge-multiple: true | |
| - name: Log in to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Push multi-architecture image | |
| working-directory: ${{ runner.temp }}/digests | |
| env: | |
| IMAGE: ghcr.io/${{ github.repository }}/agentgateway:${{ needs.source.outputs.short_sha }} | |
| run: | | |
| docker buildx imagetools create \ | |
| --tag "$IMAGE" \ | |
| $(printf 'ghcr.io/${{ github.repository }}/agentgateway@sha256:%s ' *) | |
| digest=$(docker buildx imagetools inspect "$IMAGE" --format '{{json .}}' | jq -r '.manifest.digest') | |
| echo "$IMAGE@$digest" >> "$GITHUB_STEP_SUMMARY" |