Skip to content

Commit 2c8a2a8

Browse files
authored
Docker: Only cache qemu/buildx on default branch (#11241)
Docker qemu / buildx are eating up lots of cache for little benefit. Remove unless we're building from the main branch.
1 parent 67e12dc commit 2c8a2a8

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

.github/workflows/docker_build.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ jobs:
4545
outputs:
4646
digest: ${{ steps.docker_variant.outputs.digest }}
4747
runs-on: ${{ inputs.runs-on }}
48+
env:
49+
# Only cache on default branch (develop).
50+
# 'docker/' actions don't support separate Restore/Save actions, so we have to disable caching entirely on PRs/merge_queue.
51+
USE_CACHE: ${{ github.ref_name == github.event.repository.default_branch }}
4852
steps:
4953
- name: Checkout code
5054
uses: actions/checkout@v7
@@ -59,11 +63,12 @@ jobs:
5963
- name: Set up QEMU
6064
uses: docker/setup-qemu-action@v4
6165
with:
62-
cache-image: true
66+
cache-image: ${{ env.USE_CACHE }}
6367

6468
- name: Docker setup
6569
uses: docker/setup-buildx-action@v4
6670
with:
71+
cache-binary: ${{ env.USE_CACHE }}
6772
# Add Google/Amazon DockerHub mirrors to buildkit config
6873
# https://docs.docker.com/build/ci/github-actions/configure-builder/#registry-mirror
6974
buildkitd-config-inline: |

0 commit comments

Comments
 (0)