Skip to content

Commit d79b7e2

Browse files
authored
Update main.yml
1 parent 802ca67 commit d79b7e2

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

.github/workflows/main.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,25 @@ jobs:
4242
if: env.CACHE_HIT == 'true'
4343
shell: pwsh
4444
run: |
45-
docker build --cache-from app:latest -f docker/mount.dockerfile -t app:latest .
45+
New-Item -Path build.log -ItemType File -Force
46+
docker build --cache-from app:latest --progress=plain -f docker/mount.dockerfile -t app:latest . | Tee-Object -FilePath build.log
47+
$total_steps = (Get-Content build.log | Select-String -Pattern '^Step [0-9]+/' | Measure-Object).Count
48+
$cache_hits = (Get-Content build.log | Select-String -Pattern '---> Using cache' | Measure-Object).Count
49+
if ($cache_hits -eq $total_steps) {
50+
echo "FULL_CACHE_HIT=true" >> $env:GITHUB_ENV
51+
Write-Host "Full cache hit, all layers were used from source cache."
52+
} else {
53+
Write-Host "Partial cache hit, some layers were rebuilt."
54+
}
4655
4756
- name: Save Docker Image to TAR
57+
if: env.FULL_CACHE_HIT != 'true'
4858
shell: pwsh
4959
run: |
5060
docker save -o cache-image.tar app:latest
51-
61+
5262
- name: Cache Image TAR
63+
if: env.FULL_CACHE_HIT != 'true'
5364
uses: actions/cache@v4
5465
with:
5566
path: cache-image.tar

0 commit comments

Comments
 (0)