release.yml•3.95 kB
name: Build and Push Docker Image
on:
  push:
    tags:
      - 'v*'
      - 'agent-v*'
env:
  SERVICE_IMAGE_NAME: "keboola/mcp-server"
jobs:
  build-and-push:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      id-token: write
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3
      - name: Extract metadata
        id: meta
        uses: docker/metadata-action@v5
        with:
          images: |
            ${{ env.SERVICE_IMAGE_NAME }}
          tags: |
            type=sha,format=long
            type=raw,value=production-${{ github.sha }},enable=${{ (startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/tags/agent-v')) && !contains(github.ref, '-dev.') }}
            type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '-dev.') }}
            type=raw,value=canary-orion-${{ github.sha }},enable=${{ (startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/tags/agent-v')) && contains(github.ref, '-dev.') }}
      - name: Docker login
        uses: docker/login-action@v3
        with:
          username: ${{ secrets.DOCKERHUB_PUSH_USER }}
          password: ${{ secrets.DOCKERHUB_PUSH_TOKEN }}
      # Build for tests (single-arch, load into daemon)
      - name: Build Docker image
        uses: docker/build-push-action@v6
        with:
          context: .
          file: ./Dockerfile # Explicitly specify the Dockerfile path
          tags: "keboola/mcp-server:ci"
          push: false
          load: true
          cache-from: type=gha
          cache-to: type=gha,mode=max
      - name: Run simple e2e test
        run: |
          set -euo pipefail
          STORAGE_API_TOKEN=${{ secrets.INTEGTEST_STORAGE_TOKEN }} STORAGE_API_URL=${{ vars.INTEGTEST_STORAGE_API_URL }} WORKSPACE_SCHEMA=${{ vars.INTEGTEST_WORKSPACE_SCHEMA }} ./tests/docker/ci.sh
      # Push multi-arch image (no load)
      - name: Push Docker image
        uses: docker/build-push-action@v6
        with:
          context: .
          file: ./Dockerfile
          platforms: linux/amd64,linux/arm64
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}
          push: true
          cache-from: type=gha
          cache-to: type=gha,mode=max
      - name: Trigger image tag update for canary-orion
        uses: ./.github/actions/trigger-image-tag-update
        if: startsWith(github.ref, 'refs/tags/v') && contains(github.ref, '-dev.')
        with:
          helm-chart: "mcp-server"
          image-tag: canary-orion-${{ github.sha }}
          github-app-private-key: ${{ secrets.GITOPS_KBC_STACKS_TRIGGER_APP_PVK }}
      - name: Trigger image tag update for production
        uses: ./.github/actions/trigger-image-tag-update
        if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '-dev.')
        with:
          helm-chart: "mcp-server"
          image-tag: production-${{ github.sha }}
          github-app-private-key: ${{ secrets.GITOPS_KBC_STACKS_TRIGGER_APP_PVK }}
      - name: Trigger image tag update for canary-orion (agent)
        uses: ./.github/actions/trigger-image-tag-update
        if: startsWith(github.ref, 'refs/tags/agent-v') && contains(github.ref, '-dev.')
        with:
          helm-chart: "mcp-server-agent"
          image-tag: canary-orion-${{ github.sha }}
          github-app-private-key: ${{ secrets.GITOPS_KBC_STACKS_TRIGGER_APP_PVK }}
      - name: Trigger image tag update for production (agent)
        uses: ./.github/actions/trigger-image-tag-update
        if: startsWith(github.ref, 'refs/tags/agent-v') && !contains(github.ref, '-dev.')
        with:
          helm-chart: "mcp-server-agent"
          image-tag: production-${{ github.sha }}
          github-app-private-key: ${{ secrets.GITOPS_KBC_STACKS_TRIGGER_APP_PVK }}