added option to skip base image check
This commit is contained in:
+46
-23
@@ -5,20 +5,25 @@ on:
|
|||||||
# Runs every day at 3:00 AM UTC
|
# Runs every day at 3:00 AM UTC
|
||||||
- cron: '0 3 * * *'
|
- cron: '0 3 * * *'
|
||||||
workflow_dispatch: # Allows manual triggering
|
workflow_dispatch: # Allows manual triggering
|
||||||
|
inputs:
|
||||||
|
skip_image_check:
|
||||||
|
description: 'Skip image check and force build'
|
||||||
|
required: false
|
||||||
|
default: 'false'
|
||||||
|
type: choice
|
||||||
|
options:
|
||||||
|
- 'true'
|
||||||
|
- 'false'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check-images:
|
get-mlflow-full-base-image-digest:
|
||||||
|
if: github.event.inputs.skip_image_check != 'true'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
base_image_digest: ${{ steps.mlflow-base.outputs.digest }}
|
base_image_digest: ${{ steps.mlflow-full.outputs.base_image_digest }}
|
||||||
should_build: ${{ steps.decision.outputs.should_build }}
|
success: ${{ steps.mlflow-full.outputs.success }}
|
||||||
steps:
|
steps:
|
||||||
- name: Log in to Gitea Container Registry
|
- name: Get MLflow-full base image digest
|
||||||
run: |
|
|
||||||
mkdir -p ~/.docker
|
|
||||||
echo '{"insecure-registries": ["10.0.0.2:3000"]}' > ~/.docker/config.json
|
|
||||||
echo "${{ secrets.CI_RUNNER_TOKEN }}" | docker login 10.0.0.2:3000 --username "${{ gitea.actor }}" --password-stdin
|
|
||||||
- name: Check MLflow-full base image digest
|
|
||||||
id: mlflow-full
|
id: mlflow-full
|
||||||
env:
|
env:
|
||||||
CI_RUNNER_TOKEN: ${{ secrets.CI_RUNNER_TOKEN }}
|
CI_RUNNER_TOKEN: ${{ secrets.CI_RUNNER_TOKEN }}
|
||||||
@@ -29,21 +34,21 @@ jobs:
|
|||||||
"https://gitea.gt-proj.com/v2/token?service=container_registry&scope=repository:brian/mlflow-full:pull" \
|
"https://gitea.gt-proj.com/v2/token?service=container_registry&scope=repository:brian/mlflow-full:pull" \
|
||||||
| jq -r '.token // empty')
|
| jq -r '.token // empty')
|
||||||
if [ -z "$REGISTRY_TOKEN" ]; then
|
if [ -z "$REGISTRY_TOKEN" ]; then
|
||||||
echo "digest_found=false" >> $GITHUB_OUTPUT
|
echo "success=false" >> $GITHUB_OUTPUT
|
||||||
echo "Failed to obtain registry token"
|
echo "Failed to obtain registry token"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
# Inspect the manifest of the MLflow-full image
|
# Inspect the manifest of the MLflow-full image
|
||||||
MANIFEST=$(docker manifest inspect "gitea.gt-proj.com/brian/mlflow-full:latest" 2>/dev/null || echo "{}")
|
MANIFEST=$(docker manifest inspect "gitea.gt-proj.com/brian/mlflow-full:latest" 2>/dev/null || echo "{}")
|
||||||
if [ "$MANIFEST" == "{}" ]; then
|
if [ "$MANIFEST" == "{}" ]; then
|
||||||
echo "digest_found=false" >> $GITHUB_OUTPUT
|
echo "success=false" >> $GITHUB_OUTPUT
|
||||||
echo "MLflow-full manifest not found"
|
echo "MLflow-full manifest not found"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
# Extract digest for linux/amd64 platform
|
# Extract digest for linux/amd64 platform
|
||||||
DIGEST=$(echo "$MANIFEST" | jq -r '.manifests[]? | select(.platform.architecture == "amd64" and .platform.os == "linux") | .digest // empty')
|
DIGEST=$(echo "$MANIFEST" | jq -r '.manifests[]? | select(.platform.architecture == "amd64" and .platform.os == "linux") | .digest // empty')
|
||||||
if [ -z "$DIGEST" ]; then
|
if [ -z "$DIGEST" ]; then
|
||||||
echo "digest_found=false" >> $GITHUB_OUTPUT
|
echo "success=false" >> $GITHUB_OUTPUT
|
||||||
echo "No suitable manifest found for linux/amd64"
|
echo "No suitable manifest found for linux/amd64"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@@ -52,51 +57,70 @@ jobs:
|
|||||||
-H "Authorization: Bearer $REGISTRY_TOKEN" \
|
-H "Authorization: Bearer $REGISTRY_TOKEN" \
|
||||||
"https://gitea.gt-proj.com/v2/brian/mlflow-full/manifests/$DIGEST" 2>/dev/null || echo "{}")
|
"https://gitea.gt-proj.com/v2/brian/mlflow-full/manifests/$DIGEST" 2>/dev/null || echo "{}")
|
||||||
if [ "$PLATFORM_MANIFEST" == "{}" ]; then
|
if [ "$PLATFORM_MANIFEST" == "{}" ]; then
|
||||||
echo "digest_found=false" >> $GITHUB_OUTPUT
|
echo "success=false" >> $GITHUB_OUTPUT
|
||||||
echo "Failed to fetch platform-specific manifest"
|
echo "Failed to fetch platform-specific manifest"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
# Extract config blob digest
|
# Extract config blob digest
|
||||||
CONFIG_DIGEST=$(echo "$PLATFORM_MANIFEST" | jq -r '.config.digest // empty')
|
CONFIG_DIGEST=$(echo "$PLATFORM_MANIFEST" | jq -r '.config.digest // empty')
|
||||||
if [ -z "$CONFIG_DIGEST" ]; then
|
if [ -z "$CONFIG_DIGEST" ]; then
|
||||||
echo "digest_found=false" >> $GITHUB_OUTPUT
|
echo "success=false" >> $GITHUB_OUTPUT
|
||||||
echo "No config digest found in platform manifest"
|
echo "No config digest found in platform manifest"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
# Fetch the configuration blob to get labels
|
# Fetch the configuration blob to get labels
|
||||||
CONFIG_BLOB=$(curl -s "http://gitea.gt-proj.com/v2/brian/mlflow-full/blobs/$CONFIG_DIGEST" 2>/dev/null || echo "{}")
|
CONFIG_BLOB=$(curl -s "http://gitea.gt-proj.com/v2/brian/mlflow-full/blobs/$CONFIG_DIGEST" 2>/dev/null || echo "{}")
|
||||||
if [ "$CONFIG_BLOB" == "{}" ]; then
|
if [ "$CONFIG_BLOB" == "{}" ]; then
|
||||||
echo "digest_found=false" >> $GITHUB_OUTPUT
|
echo "success=false" >> $GITHUB_OUTPUT
|
||||||
echo "Failed to fetch config blob"
|
echo "Failed to fetch config blob"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
# Extract base image digest label from config
|
# Extract base image digest label from config
|
||||||
BASE_IMAGE_DIGEST=$(echo "$CONFIG_BLOB" | jq -r '.config.Labels["base-image.digest"] // empty')
|
BASE_IMAGE_DIGEST=$(echo "$CONFIG_BLOB" | jq -r '.config.Labels["base-image.digest"] // empty')
|
||||||
if [ -z "$BASE_IMAGE_DIGEST" ]; then
|
if [ -z "$BASE_IMAGE_DIGEST" ]; then
|
||||||
echo "digest_found=false" >> $GITHUB_OUTPUT
|
echo "success=false" >> $GITHUB_OUTPUT
|
||||||
echo "No base-image.digest label found in MLflow-full image"
|
echo "No base-image.digest label found in MLflow-full image"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "base_image_digest=$BASE_IMAGE_DIGEST" >> $GITHUB_OUTPUT
|
echo "base_image_digest=$BASE_IMAGE_DIGEST" >> $GITHUB_OUTPUT
|
||||||
echo "digest_found=true" >> $GITHUB_OUTPUT
|
echo "success=true" >> $GITHUB_OUTPUT
|
||||||
echo "Base image digest from MLflow-full image: $BASE_IMAGE_DIGEST"
|
echo "Base image digest from MLflow-full image: $BASE_IMAGE_DIGEST"
|
||||||
- name: Check MLflow base image digest
|
get-mlflow-digest:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
digest: ${{ steps.mlflow-base.outputs.digest }}
|
||||||
|
success: ${{ steps.mlflow-base.outputs.success }}
|
||||||
|
steps:
|
||||||
|
- name: Get MLflow base image digest
|
||||||
id: mlflow-base
|
id: mlflow-base
|
||||||
if: steps.mlflow-full.outputs.digest_found == 'true'
|
|
||||||
run: |
|
run: |
|
||||||
MANIFEST=$(docker manifest inspect ghcr.io/mlflow/mlflow:latest 2>/dev/null || echo "{}")
|
MANIFEST=$(docker manifest inspect ghcr.io/mlflow/mlflow:latest 2>/dev/null || echo "{}")
|
||||||
if [ "$MANIFEST" != "{}" ]; then
|
if [ "$MANIFEST" != "{}" ]; then
|
||||||
DIGEST=$(echo "$MANIFEST" | jq -r '.manifests[]? | select(.platform.architecture == "amd64" and .platform.os == "linux") | .digest // empty')
|
DIGEST=$(echo "$MANIFEST" | jq -r '.manifests[]? | select(.platform.architecture == "amd64" and .platform.os == "linux") | .digest // empty')
|
||||||
echo "digest=$DIGEST" >> $GITHUB_OUTPUT
|
echo "digest=$DIGEST" >> $GITHUB_OUTPUT
|
||||||
echo "digest_found=true" >> $GITHUB_OUTPUT
|
echo "success=true" >> $GITHUB_OUTPUT
|
||||||
echo "Digest found for MLflow base image: $DIGEST"
|
echo "Digest found for MLflow base image: $DIGEST"
|
||||||
else
|
else
|
||||||
echo "digest_found=false" >> $GITHUB_OUTPUT
|
echo "success=false" >> $GITHUB_OUTPUT
|
||||||
echo "MLflow base image not found"
|
echo "MLflow base image not found"
|
||||||
fi
|
fi
|
||||||
|
decide-to-build:
|
||||||
|
if: always() # Run regardless of dependency status
|
||||||
|
needs:
|
||||||
|
- get-mlflow-full-base-image-digest
|
||||||
|
- get-mlflow-digest
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
should_build: ${{ steps.decision.outputs.should_build }}
|
||||||
|
steps:
|
||||||
- name: Build decision
|
- name: Build decision
|
||||||
id: decision
|
id: decision
|
||||||
run: |
|
run: |
|
||||||
|
if [ github.event.inputs.skip_image_check == 'true' ]; then
|
||||||
|
echo "Image check skipped, forcing build"
|
||||||
|
echo "should_build=true" >> $GITHUB_OUTPUT
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
if [ "${{ steps.mlflow-base.outputs.manifest_found }}" == "true" ] && \
|
if [ "${{ steps.mlflow-base.outputs.manifest_found }}" == "true" ] && \
|
||||||
[ "${{ steps.mlflow-full.outputs.manifest_found }}" == "true" ]; then
|
[ "${{ steps.mlflow-full.outputs.manifest_found }}" == "true" ]; then
|
||||||
echo "✅ Both MLflow base and MLflow-full images found"
|
echo "✅ Both MLflow base and MLflow-full images found"
|
||||||
@@ -115,8 +139,7 @@ jobs:
|
|||||||
echo "should_build=false" >> $GITHUB_OUTPUT
|
echo "should_build=false" >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
build-and-publish:
|
build-and-publish:
|
||||||
needs: check-images
|
needs: decide-to-build
|
||||||
if: needs.check-images.outputs.should_build == 'true'
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
|
|||||||
Reference in New Issue
Block a user