Files
2026-07-13 13:22:34 +08:00

130 lines
4.2 KiB
YAML

name: Push-Images
on:
release:
types:
- published
- edited
defaults:
run:
shell: bash
permissions: {}
jobs:
push-images:
# Only run for version tags (vX.Y.Z); skips non-version release tags like `model-catalog/latest`.
if: "startsWith(github.ref_name, 'v') && !contains(github.ref_name, 'rc')"
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
packages: write # to push to ghcr.io
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- uses: ./.github/actions/setup-python
- name: Set up QEMU
uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
- name: Login to GitHub Container Registry
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Check if should update latest tag
id: check_latest
run: |
CURRENT_VERSION=${GITHUB_REF_NAME#v}
HIGHEST_VERSION=$(gh release list --exclude-pre-releases --exclude-drafts --limit 100 | \
grep -E '^v[0-9]+\.[0-9]+\.[0-9]+\s' | \
awk '{print $1}' | \
sed 's/^v//' | \
sort -V | \
tail -n1)
if [ -z "$HIGHEST_VERSION" ] || [ "$(echo -e "$CURRENT_VERSION\n$HIGHEST_VERSION" | sort -V | tail -n1)" = "$CURRENT_VERSION" ]; then
echo "should_update_latest=true" >> $GITHUB_OUTPUT
else
echo "should_update_latest=false" >> $GITHUB_OUTPUT
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Gather Docker Metadata for Tracking
id: meta
uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0
with:
images: |
ghcr.io/mlflow/mlflow
tags: |
type=ref,event=tag
type=raw,value=latest,enable=${{ steps.check_latest.outputs.should_update_latest == 'true' }}
- name: Gather Docker Metadata for Full Image
id: meta-full
uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0
with:
images: |
ghcr.io/mlflow/mlflow
tags: |
type=ref,event=tag,suffix=-full
type=raw,value=latest-full,enable=${{ steps.check_latest.outputs.should_update_latest == 'true' }}
- name: Build and Push Base Image
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7.0.0
with:
context: docker
push: true
tags: ${{ steps.meta.outputs.tags }}
platforms: linux/amd64,linux/arm64
build-args: |
VERSION=${{ steps.meta.outputs.version }}
- name: Build and Push Base Full Image
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7.0.0
with:
context: docker
file: docker/Dockerfile.full
push: true
tags: ${{ steps.meta-full.outputs.tags }}
platforms: linux/amd64,linux/arm64
build-args: |
VERSION=${{ steps.meta.outputs.version }}
- name: Gather Docker Metadata for Model Server
id: modelmeta
uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0
with:
images: |
ghcr.io/mlflow/model-server
tags: |
type=ref,event=tag
type=raw,value=latest,enable=${{ steps.check_latest.outputs.should_update_latest == 'true' }}
- name: Build Model Server Image
run: |
uv pip install --system .
mlflow models build-docker -n model-server:latest --mlflow-home `pwd`
- name: Push Model Server Image
env:
TAGS: ${{ steps.modelmeta.outputs.tags }}
run: |
set -x
tags=$(echo -n "$TAGS" | tr '\n' ' ')
for tag in $tags; do
docker tag model-server:latest $tag
docker push $tag
done