Skip to content

Promote Model to Production #33

Promote Model to Production

Promote Model to Production #33

name: Promote Model to Production
on:
workflow_dispatch:
inputs:
source_namespace:
description: 'Source namespace (e.g., aistaging)'
required: false
type: string
default: 'aistaging'
target_namespace:
description: 'Target namespace (e.g., ai)'
required: false
type: string
default: 'ai'
image:
description: 'Image to promote: repository:tag for specific image (e.g., smollm2:135M-Q4_K_M) OR repository for entire repo (e.g., smollm2)'
required: true
type: string
permissions:
contents: read
jobs:
promote-model:
runs-on: ubuntu-latest
steps:
- name: Validate inputs
run: |
echo "Validating workflow inputs..."
if [ -z "${{ inputs.image }}" ]; then
echo "Error: image is required"
exit 1
fi
echo "All required inputs provided ✓"
- name: Set up Crane
run: |
echo "Installing crane..."
curl -LO https://github.com/google/go-containerregistry/releases/latest/download/go-containerregistry_Linux_x86_64.tar.gz
tar -xzvf go-containerregistry_Linux_x86_64.tar.gz crane
sudo mv crane /usr/local/bin/
crane version
echo "Crane installed successfully ✓"
- name: Log in to DockerHub
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKER_USER }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKER_OAT }}
run: |
echo "Authenticating to DockerHub..."
crane auth login index.docker.io -u "$DOCKERHUB_USERNAME" -p "$DOCKERHUB_TOKEN"
echo "DockerHub authentication successful ✓"
- name: Promote model
run: |
if [[ "${{ inputs.image }}" == *":"* ]]; then
# Single tag promotion
REPOSITORY=$(echo "${{ inputs.image }}" | cut -d':' -f1)
TAG=$(echo "${{ inputs.image }}" | cut -d':' -f2)
SOURCE_IMAGE="${{ inputs.source_namespace }}/${{ inputs.image }}"
TARGET_IMAGE="docker.io/${{ inputs.target_namespace }}/${{ inputs.image }}"
echo "=== Single Tag Promotion ==="
echo "Promoting: ${{ inputs.image }}"
echo "From: $SOURCE_IMAGE"
echo "To: $TARGET_IMAGE"
crane copy "$SOURCE_IMAGE" "$TARGET_IMAGE"
echo "✅ Successfully promoted ${{ inputs.image }} from ${{ inputs.source_namespace }} to ${{ inputs.target_namespace }}"
else
# Repository promotion (all tags)
REPOSITORY="${{ inputs.image }}"
SOURCE_REPO="${{ inputs.source_namespace }}/$REPOSITORY"
TARGET_REPO="docker.io/${{ inputs.target_namespace }}/$REPOSITORY"
echo "=== Repository Promotion (All Tags) ==="
echo "Promoting all tags for: $REPOSITORY"
echo "From: $SOURCE_REPO"
echo "To: $TARGET_REPO"
# Verify source repository exists
if ! crane ls "$SOURCE_REPO" >/dev/null 2>&1; then
echo "❌ Error: Source repository $SOURCE_REPO does not exist or has no tags"
exit 1
fi
# Show tags being copied
echo "Tags to be copied:"
crane ls "$SOURCE_REPO"
crane copy --all-tags "$SOURCE_REPO" "$TARGET_REPO"
echo "✅ Successfully promoted all tags for $REPOSITORY from ${{ inputs.source_namespace }} to ${{ inputs.target_namespace }}"
fi