updated to check digest version of base image
This commit is contained in:
@@ -7,13 +7,66 @@ on:
|
||||
workflow_dispatch: # Allows manual triggering
|
||||
|
||||
jobs:
|
||||
build-and-publish:
|
||||
check-images:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
outputs:
|
||||
base_image_digest: ${{ steps.mlflow-base.outputs.base_image_digest }}
|
||||
should_build: ${{ steps.decision.outputs.should_build }}
|
||||
steps:
|
||||
- name: Log in to Gitea Container Registry
|
||||
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 image
|
||||
id: mlflow-full
|
||||
run: |
|
||||
MANIFEST=$(docker manifest inspect "10.0.0.2:3000/brian/mlflow-full:latest" 2>/dev/null || echo "{}")
|
||||
if [ "$MANIFEST" != "{}" ]; then
|
||||
DIGEST=$(echo "$MANIFEST" | jq -r '.manifests[]? | select(.platform.architecture == "amd64" and .platform.os == "linux") | .digest // empty')
|
||||
echo "digest=$DIGEST" >> $GITHUB_OUTPUT
|
||||
echo "manifest_found=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "manifest_found=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
- name: Check MLflow base image
|
||||
id: mlflow-base
|
||||
if: steps.mlflow-full.outputs.found == 'true'
|
||||
run: |
|
||||
MANIFEST=$(docker manifest inspect ghcr.io/mlflow/mlflow:latest 2>/dev/null || echo "{}")
|
||||
if [ "$MANIFEST" != "{}" ]; then
|
||||
DIGEST=$(echo "$MANIFEST" | jq -r '.manifests[]? | select(.platform.architecture == "amd64" and .platform.os == "linux") | .digest // empty')
|
||||
echo "digest=$DIGEST" >> $GITHUB_OUTPUT
|
||||
echo "manifest_found=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "manifest_found=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
- name: Build decision
|
||||
id: decision
|
||||
run: |
|
||||
if [ "${{ steps.mlflow-base.outputs.manifest_found }}" == "true" ] && \
|
||||
[ "${{ steps.mlflow-full.outputs.manifest_found }}" == "true" ]; then
|
||||
echo "✅ Both MLflow base and MLflow-full images found"
|
||||
echo "should_build=true" >> $GITHUB_OUTPUT
|
||||
elif [ "${{ steps.mlflow-base.outputs.manifest_found }}" != "true" ]; then
|
||||
echo "❌ MLflow base image not found"
|
||||
echo "should_build=false" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "❌ MLflow-full image not found"
|
||||
echo "should_build=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
build-and-publish:
|
||||
needs: check-images
|
||||
if: needs.check-images.outputs.should_build == 'true'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Build skipped
|
||||
if: steps.build_decision.outputs.should_build == 'false'
|
||||
run: |
|
||||
echo "Build skipped: ${{ steps.build_decision.outputs.reason }}"
|
||||
exit 1
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
with:
|
||||
@@ -21,7 +74,6 @@ jobs:
|
||||
[registry."10.0.0.2:3000"]
|
||||
http = true
|
||||
insecure = true
|
||||
|
||||
- name: Log in to Gitea Container Registry
|
||||
run: |
|
||||
# Configure Docker to allow insecure registry for this session
|
||||
@@ -33,7 +85,6 @@ jobs:
|
||||
|
||||
# Login using direct docker command
|
||||
echo "${{ secrets.CI_RUNNER_TOKEN }}" | docker login 10.0.0.2:3000 --username "${{ gitea.actor }}" --password-stdin
|
||||
|
||||
- name: Extract metadata
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
@@ -41,9 +92,9 @@ jobs:
|
||||
images: 10.0.0.2:3000/${{ gitea.repository_owner }}/${{ gitea.event.repository.name }}
|
||||
tags: |
|
||||
type=schedule,pattern={{date 'YYYYMMDD'}}
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
|
||||
type=raw,value=latest
|
||||
- name: Build and push Docker image
|
||||
id: build-publish
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
@@ -52,8 +103,11 @@ jobs:
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
build-args: |
|
||||
BASE_IMAGE_DIGEST=${{ needs.check-images.outputs.base_image_digest }}
|
||||
- name: Update deployment info
|
||||
if: steps.build-publish.outputs.success == 'true'
|
||||
run: |
|
||||
echo "Docker image built and pushed successfully at $(date)"
|
||||
echo "Image tags: ${{ steps.meta.outputs.tags }}"
|
||||
echo "Image tags:"
|
||||
echo "${{ steps.meta.outputs.tags }}"
|
||||
|
||||
Reference in New Issue
Block a user