Skip to content

Commit d3616ff

Browse files
committed
try add actions/cache for windows container
1 parent 70ca070 commit d3616ff

1 file changed

Lines changed: 23 additions & 22 deletions

File tree

.github/workflows/release_docker_win.yml

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,18 @@ jobs:
4343
- name: Checkout
4444
uses: actions/checkout@v4
4545

46+
- name: Set up Docker Buildx
47+
uses: docker/setup-buildx-action@v3
48+
49+
- name: Cache Docker layers
50+
uses: actions/cache@v4
51+
with:
52+
path: |
53+
C:\Users\runneradmin\.docker\buildx\cache
54+
key: docker-win-${{ matrix.windows_version }}-${{ matrix.container_type }}-${{ github.sha }}
55+
restore-keys: |
56+
docker-win-${{ matrix.windows_version }}-${{ matrix.container_type }}-
57+
4658
- name: Login to GitHub Container Registry
4759
if: env.IMAGE_PUSH == 'true'
4860
uses: docker/login-action@v3
@@ -98,25 +110,14 @@ jobs:
98110
Write-Host "Tags: $tagsString"
99111
100112
- name: Build and push Windows container
101-
shell: pwsh
102-
run: |
103-
$tags = "${{ steps.meta.outputs.tags }}".Split(",")
104-
$tagArgs = @()
105-
foreach ($tag in $tags) {
106-
$tagArgs += "-t"
107-
$tagArgs += $tag.Trim()
108-
}
109-
110-
docker build `
111-
--build-arg WINDOWS_VERSION=${{ steps.tag.outputs.windows_version }} `
112-
--build-arg WINDOWS_TYPE=${{ matrix.container_type }} `
113-
-f Dockerfile.windows `
114-
$tagArgs `
115-
.
116-
117-
if ("${{ env.IMAGE_PUSH }}" -eq "true") {
118-
foreach ($tag in $tags) {
119-
Write-Host "Pushing $($tag.Trim())"
120-
docker push $tag.Trim()
121-
}
122-
}
113+
uses: docker/build-push-action@v6
114+
with:
115+
context: .
116+
file: Dockerfile.windows
117+
build-args: |
118+
WINDOWS_VERSION=${{ steps.tag.outputs.windows_version }}
119+
WINDOWS_TYPE=${{ matrix.container_type }}
120+
push: ${{ env.IMAGE_PUSH }}
121+
tags: ${{ steps.meta.outputs.tags }}
122+
cache-from: type=gha
123+
cache-to: type=gha,mode=max

0 commit comments

Comments
 (0)