Skip to content

Commit 845197d

Browse files
authored
Update main.yml
1 parent 57e0f20 commit 845197d

File tree

1 file changed

+3
-20
lines changed

1 file changed

+3
-20
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,37 +32,20 @@ jobs:
3232
echo "CACHE_HIT=true" >> $env:GITHUB_ENV
3333
}
3434
35-
- uses: fawazahmed0/action-debug-vscode@main
36-
3735
- name: Build Image Without Cache
3836
if: env.CACHE_HIT != 'true'
3937
shell: pwsh
4038
run: |
4139
docker build -t app:latest .
42-
43-
- name: Build Image With Cache
44-
if: env.CACHE_HIT == 'true'
45-
shell: pwsh
46-
run: |
47-
New-Item -Path build.log -ItemType File -Force
48-
docker build --cache-from app:latest -t app:latest . | Tee-Object -FilePath build.log
49-
$cache_hits = (Get-Content build.log | Select-String -Pattern '---> Using cache' | Measure-Object).Count
50-
$steps_with_cache = (Get-Content build.log | Select-String -Pattern '^Step [0-9]+/' | Where-Object { $_ -notmatch 'FROM' } | Measure-Object).Count
51-
if ($cache_hits -eq $steps_with_cache) {
52-
echo "FULL_CACHE_HIT=true" >> $env:GITHUB_ENV
53-
Write-Host "Full cache hit, all layers were used from source cache."
54-
} else {
55-
Write-Host "Partial cache hit, some layers were rebuilt."
56-
}
57-
40+
5841
- name: Save Docker Image to TAR
59-
if: env.FULL_CACHE_HIT != 'true'
42+
if: env.CACHE_HIT != 'true'
6043
shell: pwsh
6144
run: |
6245
docker save -o cache-image.tar app:latest
6346
6447
- name: Cache Image TAR
65-
if: env.FULL_CACHE_HIT != 'true'
48+
if: env.CACHE_HIT != 'true'
6649
uses: actions/cache@v4
6750
with:
6851
path: cache-image.tar

0 commit comments

Comments
 (0)