File tree Expand file tree Collapse file tree 1 file changed +3
-20
lines changed Expand file tree Collapse file tree 1 file changed +3
-20
lines changed Original file line number Diff line number Diff line change @@ -32,37 +32,20 @@ jobs:
32
32
echo "CACHE_HIT=true" >> $env:GITHUB_ENV
33
33
}
34
34
35
- - uses : fawazahmed0/action-debug-vscode@main
36
-
37
35
- name : Build Image Without Cache
38
36
if : env.CACHE_HIT != 'true'
39
37
shell : pwsh
40
38
run : |
41
39
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
+
58
41
- name : Save Docker Image to TAR
59
- if : env.FULL_CACHE_HIT != 'true'
42
+ if : env.CACHE_HIT != 'true'
60
43
shell : pwsh
61
44
run : |
62
45
docker save -o cache-image.tar app:latest
63
46
64
47
- name : Cache Image TAR
65
- if : env.FULL_CACHE_HIT != 'true'
48
+ if : env.CACHE_HIT != 'true'
66
49
uses : actions/cache@v4
67
50
with :
68
51
path : cache-image.tar
You can’t perform that action at this time.
0 commit comments