Skip to content

Commit 802ca67

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

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

.github/workflows/main.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,31 @@ jobs:
1919
uses: actions/cache@v4
2020
with:
2121
path: cache-image.tar
22-
key: docker-image-${{ runner.os }}-${{ github.run_id }}
22+
key: docker-image-${{ runner.os }}-${{ github.sha }}
2323
restore-keys: |
2424
docker-image-${{ runner.os }}-
2525
2626
- name: Load Cached Image
2727
shell: pwsh
28-
if: success() && hashFiles('cache-image.tar') != ''
28+
id: load_cache
2929
run: |
30-
docker load -i cache-image.tar
30+
if (Test-Path cache-image.tar) {
31+
docker load -i cache-image.tar
32+
echo "CACHE_HIT=true" >> $env:GITHUB_ENV
33+
}
3134
32-
- name: Build Image
35+
- name: Build Image Without Cache
36+
if: env.CACHE_HIT != 'true'
3337
shell: pwsh
3438
run: |
3539
docker build -f docker/mount.dockerfile -t app:latest .
3640
41+
- name: Build Image With Cache
42+
if: env.CACHE_HIT == 'true'
43+
shell: pwsh
44+
run: |
45+
docker build --cache-from app:latest -f docker/mount.dockerfile -t app:latest .
46+
3747
- name: Save Docker Image to TAR
3848
shell: pwsh
3949
run: |
@@ -43,6 +53,6 @@ jobs:
4353
uses: actions/cache@v4
4454
with:
4555
path: cache-image.tar
46-
key: docker-image-${{ runner.os }}-${{ github.run_id }}
56+
key: docker-image-${{ runner.os }}-${{ github.sha }}
4757
restore-keys: |
4858
docker-image-${{ runner.os }}-

0 commit comments

Comments
 (0)