🔧 refactor: add fallback to cache check for reliability

This commit is contained in:
2026-04-08 11:29:11 +02:00
parent 48cb881af0
commit 3f84c91495

View File

@@ -76,22 +76,29 @@ jobs:
echo "Dependency hash: $DEPS_HASH"
echo "deps_hash=$DEPS_HASH" >> $GITHUB_OUTPUT
- name: Check for existing cache (optimized)
- name: Check for existing cache (optimized with fallback)
id: check_cache
run: |
# Check if image exists in registry using optimized approach
# Check if image exists in registry using optimized approach with fallback
IMAGE_NAME="${{ env.CI_REGISTRY }}/${{ env.GITEA_ORG }}/${{ env.GITEA_REPO }}-build-cache:${{ steps.calculate_hash.outputs.deps_hash }}"
# Fast check using docker manifest inspect (lighter than pull)
echo "🔍 Checking cache: $IMAGE_NAME"
# Try manifest inspect first (fastest method)
# Try manifest inspect first (fastest method, but experimental)
if docker manifest inspect "$IMAGE_NAME" >/dev/null 2>&1; then
echo "✅ Cache hit - using existing build cache (manifest inspect)"
echo "cache_hit=true" >> $GITHUB_OUTPUT
else
echo "⚠️ Cache miss - will build new cache image"
echo "cache_hit=false" >> $GITHUB_OUTPUT
# Fallback to docker pull if manifest inspect fails (more reliable)
echo "⚠️ Manifest inspect failed, falling back to docker pull..."
if docker pull "$IMAGE_NAME" >/dev/null 2>&1; then
echo "✅ Cache hit - using existing build cache (fallback: docker pull)"
echo "cache_hit=true" >> $GITHUB_OUTPUT
else
echo "⚠️ Cache miss - will build new cache image"
echo "cache_hit=false" >> $GITHUB_OUTPUT
fi
fi
- name: Login to Gitea Container Registry