Skip to content

Fix /mcp Caddy routing to preserve path prefix #158

Fix /mcp Caddy routing to preserve path prefix

Fix /mcp Caddy routing to preserve path prefix #158

name: Build and Deploy
on:
push:
branches-ignore: ["*"]
tags: ["*"]
env:
GHCR_IMAGE: ghcr.io/aweber-imbi/imbi
DOCKERHUB_IMAGE: aweber/imbi
jobs:
build:
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') && github.repository == 'AWeber-Imbi/imbi'
strategy:
fail-fast: false
matrix:
include:
- platform: linux/amd64
runner: ubuntu-latest
- platform: linux/arm64
runner: ubuntu-24.04-arm
runs-on: ${{ matrix.runner }}
permissions:
contents: read
packages: write
steps:
- name: Prepare platform pair
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> "$GITHUB_ENV"
- name: Check out the repo
uses: actions/checkout@v4
with:
submodules: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Resolve tag for build args
id: ref
run: echo "tag=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
- name: Build and push by digest
id: build
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
platforms: ${{ matrix.platform }}
build-args: |
VITE_GIT_REF=${{ steps.ref.outputs.tag }}
outputs: type=image,name=${{ env.GHCR_IMAGE }},push-by-digest=true,name-canonical=true,push=true
cache-from: type=gha,scope=${{ env.PLATFORM_PAIR }}
cache-to: type=gha,mode=max,scope=${{ env.PLATFORM_PAIR }}
- 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: digests-${{ env.PLATFORM_PAIR }}
path: ${{ runner.temp }}/digests/*
if-no-files-found: error
retention-days: 1
merge:
needs: build
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Check out the repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Resolve tag and whether it is the highest semver
id: version
run: |
current="${GITHUB_REF#refs/tags/}"
echo "tag=$current" >> "$GITHUB_OUTPUT"
highest=$(git tag --sort=-v:refname | grep -E '^v?[0-9]+\.[0-9]+\.[0-9]+$' | head -n 1)
if [ "$highest" = "$current" ]; then
echo "is_latest=true" >> "$GITHUB_OUTPUT"
else
echo "is_latest=false" >> "$GITHUB_OUTPUT"
fi
- name: Download digests
uses: actions/download-artifact@v4
with:
path: ${{ runner.temp }}/digests
pattern: digests-*
merge-multiple: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Create and push manifest to GHCR
working-directory: ${{ runner.temp }}/digests
run: |
tags="-t ${{ env.GHCR_IMAGE }}:${{ steps.version.outputs.tag }}"
if [ "${{ steps.version.outputs.is_latest }}" = "true" ]; then
tags="$tags -t ${{ env.GHCR_IMAGE }}:latest"
fi
docker buildx imagetools create $tags \
$(printf '${{ env.GHCR_IMAGE }}@sha256:%s ' *)
- name: Create and push manifest to DockerHub
working-directory: ${{ runner.temp }}/digests
run: |
tags="-t ${{ env.DOCKERHUB_IMAGE }}:${{ steps.version.outputs.tag }}"
if [ "${{ steps.version.outputs.is_latest }}" = "true" ]; then
tags="$tags -t ${{ env.DOCKERHUB_IMAGE }}:latest"
fi
docker buildx imagetools create $tags \
$(printf '${{ env.GHCR_IMAGE }}@sha256:%s ' *)