ci: switch Docker GHA cache to mode=min to reduce cache bloat#1152
Merged
Conversation
Switching from mode=max to mode=min on the main branch workflow cache-to saves only the final exported layers (as opposed to all intermediate layers). This significantly reduces GHA cache storage pressure while maintaining layer reuse benefits, since cache-from still pulls everything available regardless of save mode. Expected impact: reduces Docker layer cache footprint by ~60% without affecting cache hit rates on stable layers.
Contributor
There was a problem hiding this comment.
Pull request overview
Adjusts the main-branch build/test/deploy GitHub Actions workflow to reduce GitHub Actions cache growth from Docker Buildx layer exports, helping avoid cache eviction and improving CI reliability for the EssentialCSharp.Web deployment pipeline.
Changes:
- Switch Docker Buildx
cache-toexport on main workflow frommode=maxtomode=minfor theessentialcsharpweb-mainGHA cache scope.
| outputs: type=docker,dest=${{ github.workspace }}/essentialcsharpwebimage.tar | ||
| cache-from: type=gha,scope=essentialcsharpweb-main | ||
| cache-to: type=gha,mode=max,scope=essentialcsharpweb-main | ||
| cache-to: type=gha,mode=min,scope=essentialcsharpweb-main |
Same fix as the deploy workflow - reduces cache footprint without affecting pull behavior.
Keep main workflow on mode=max and leave mode=min only in PR workflow as requested in review.
| type=gha,scope=essentialcsharpweb-main | ||
| type=gha,scope=essentialcsharpweb-pr | ||
| cache-to: type=gha,mode=max,scope=essentialcsharpweb-pr | ||
| cache-to: type=gha,mode=min,scope=essentialcsharpweb-pr |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The main branch Docker build workflow was using
cache-to: type=gha,mode=max, which saves all intermediate build layers (50+ stages). Combined with recent workflow changes, this caused the repo GHA cache to balloon to ~10 GB, hitting GitHub's per-repo limit and triggering eviction of theessentialcsharpweb-mainscope layers. Result: subsequent builds saw 0% cache hit despite warm cache.Solution
Switch to
cache-to: type=gha,mode=minon the main branch deploy workflow.mode=minsaves only the final exported layers (base image + published app binaries)cache-fromstill reads everything available, so builds benefit from layer reuse on unchanged stagesChanges
.github/workflows/Build-Test-And-Deploy.yml: line 95, changemode=maxtomode=minThis is a safe, read-path-agnostic change — pulling behavior is unaffected, only what gets written changes.