Files
Memoh/.github/workflows/docker-publish.yml
T
BBQ f472182b82 ci: optimize workflow performance
- PR docker builds use single arch (amd64 only), tag push uses dual
- Add paths-ignore to skip CI on docs-only changes
- Add concurrency groups to cancel stale runs on re-push
- Build Go binary once instead of 3x go run in migrate job
2026-02-20 03:54:43 +08:00

100 lines
3.0 KiB
YAML

name: Docker Publish
on:
push:
tags: ["v*.*.*"]
pull_request:
branches: [main]
paths-ignore:
- "docs/**"
- "**.md"
- "devenv/**"
workflow_dispatch:
concurrency:
group: docker-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
packages: write
id-token: write
jobs:
docker:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- image: server
dockerfile: docker/Dockerfile.server
- image: agent
dockerfile: docker/Dockerfile.agent
- image: web
dockerfile: docker/Dockerfile.web
- image: mcp
dockerfile: docker/Dockerfile.mcp
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
memohai/${{ matrix.image }}
ghcr.io/${{ github.repository_owner }}/${{ matrix.image }}
tags: |
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') && !contains(github.ref_name, '-') }}
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
labels: |
org.opencontainers.image.title=memoh-${{ matrix.image }}
org.opencontainers.image.description=Memoh ${{ matrix.image }} - Multi-member AI agent platform
org.opencontainers.image.vendor=memohai
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
if: startsWith(github.ref, 'refs/tags/')
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
if: startsWith(github.ref, 'refs/tags/')
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: ${{ matrix.dockerfile }}
push: ${{ startsWith(github.ref, 'refs/tags/') }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: ${{ startsWith(github.ref, 'refs/tags/') && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
build-args: |
VERSION=${{ steps.meta.outputs.version }}
COMMIT_HASH=${{ github.sha }}
BUILD_TIME=${{ fromJson(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}
VITE_API_URL=/api
VITE_AGENT_URL=/agent
provenance: true
sbom: true
cache-from: type=gha,scope=${{ matrix.image }}
cache-to: type=gha,scope=${{ matrix.image }},mode=max