⚡ perf: optimize cache check using docker manifest inspect
This commit is contained in:
@@ -76,15 +76,18 @@ jobs:
|
|||||||
echo "Dependency hash: $DEPS_HASH"
|
echo "Dependency hash: $DEPS_HASH"
|
||||||
echo "deps_hash=$DEPS_HASH" >> $GITHUB_OUTPUT
|
echo "deps_hash=$DEPS_HASH" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Check for existing cache
|
- name: Check for existing cache (optimized)
|
||||||
id: check_cache
|
id: check_cache
|
||||||
run: |
|
run: |
|
||||||
# Check if image exists in registry
|
# Check if image exists in registry using optimized approach
|
||||||
IMAGE_NAME="${{ env.CI_REGISTRY }}/${{ env.GITEA_ORG }}/${{ env.GITEA_REPO }}-build-cache:${{ steps.calculate_hash.outputs.deps_hash }}"
|
IMAGE_NAME="${{ env.CI_REGISTRY }}/${{ env.GITEA_ORG }}/${{ env.GITEA_REPO }}-build-cache:${{ steps.calculate_hash.outputs.deps_hash }}"
|
||||||
|
|
||||||
# Try to pull the image to see if it exists
|
# Fast check using docker manifest inspect (lighter than pull)
|
||||||
if docker pull "$IMAGE_NAME" >/dev/null 2>&1; then
|
echo "🔍 Checking cache: $IMAGE_NAME"
|
||||||
echo "✅ Cache hit - using existing build cache"
|
|
||||||
|
# Try manifest inspect first (fastest method)
|
||||||
|
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
|
echo "cache_hit=true" >> $GITHUB_OUTPUT
|
||||||
else
|
else
|
||||||
echo "⚠️ Cache miss - will build new cache image"
|
echo "⚠️ Cache miss - will build new cache image"
|
||||||
|
|||||||
Reference in New Issue
Block a user