mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-25 07:00:48 +09:00
ci(docker): add docker-publish workflow and clean up release.yml
Add dedicated docker-publish.yml with full CI/CD pipeline: - Build & push server/agent/web/mcp images on tag, main push, and PR - Publish to both Docker Hub and GHCR - Semver tag strategy (latest, version, major.minor, major, sha) - GHA build cache, SLSA provenance, and SBOM - PR builds validate without pushing Remove superseded dockerhub job from release.yml.
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
name: Docker Publish
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
tags: ["v*.*.*"]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
workflow_dispatch:
|
||||
|
||||
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={{is_default_branch}}
|
||||
type=ref,event=branch
|
||||
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: github.event_name != 'pull_request'
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
if: github.event_name != 'pull_request'
|
||||
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: ${{ github.event_name != 'pull_request' }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
platforms: linux/amd64,linux/arm64
|
||||
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
|
||||
@@ -8,13 +8,9 @@ on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
release:
|
||||
types:
|
||||
- published
|
||||
|
||||
jobs:
|
||||
release:
|
||||
if: github.event_name == 'push'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@@ -39,47 +35,3 @@ jobs:
|
||||
# env:
|
||||
# NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
||||
# NPM_CONFIG_PROVENANCE: true
|
||||
|
||||
dockerhub:
|
||||
if: github.event_name == 'release'
|
||||
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
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set build time
|
||||
id: vars
|
||||
run: echo "build_time=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Log in to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Build and push multi-arch image
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
file: ${{ matrix.dockerfile }}
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
tags: memohai/${{ matrix.image }}:${{ github.event.release.tag_name }}
|
||||
build-args: |
|
||||
VERSION=${{ github.event.release.tag_name }}
|
||||
COMMIT_HASH=${{ github.sha }}
|
||||
BUILD_TIME=${{ steps.vars.outputs.build_time }}
|
||||
Reference in New Issue
Block a user