From f7ffa9a9c919a9cb3762a7ab3a3bbb6fe0d405bb Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Mon, 25 Nov 2024 17:07:36 +0100 Subject: [PATCH] fix: multi-platform docker build cache misses due to overwriting other platforms --- .github/actions/docker/action.yaml | 2 ++ .github/actions/sccache/action.yaml | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/actions/docker/action.yaml b/.github/actions/docker/action.yaml index e9a9a352122..8bf1df906c5 100644 --- a/.github/actions/docker/action.yaml +++ b/.github/actions/docker/action.yaml @@ -86,6 +86,7 @@ runs: region: ${{ inputs.cache_region }} bucket: ${{ inputs.cache_bucket }} endpoint: ${{ inputs.cache_endpoint }} + prefix: "cache-layers/${{ inputs.platform }}/" cache_to_name: ${{ inputs.cache_to_name }} - name: Set HOME variable to github context @@ -160,6 +161,7 @@ runs: endpoint: ${{ inputs.cache_endpoint }} access_key_id: ${{ inputs.cache_access_key_id }} secret_access_key: ${{ inputs.cache_secret_access_key }} + platform: ${{ inputs.platform }} install: false - name: Build and push Docker image ${{ inputs.image }} diff --git a/.github/actions/sccache/action.yaml b/.github/actions/sccache/action.yaml index d64e719273a..2984abc6c05 100644 --- a/.github/actions/sccache/action.yaml +++ b/.github/actions/sccache/action.yaml @@ -17,6 +17,9 @@ inputs: secret_access_key: description: S3 endpoint secret access key required: true + platform: + description: "Platform and architecture to use when caching; helps to avoid invalid cache on different arch" + required: true install: description: "Install sccache" default: "true" @@ -50,6 +53,6 @@ runs: echo "SCCACHE_BUCKET=${{ inputs.bucket }}" >> $GITHUB_ENV echo "SCCACHE_REGION=${{ inputs.region }}" >> $GITHUB_ENV echo "SCCACHE_ENDPOINT=${{ inputs.endpoint }}" >> $GITHUB_ENV - echo "SCCACHE_S3_KEY_PREFIX=${{ runner.os }}/sccache/${{ runner.arch }}/linux-gnu" >> $GITHUB_ENV + echo "SCCACHE_S3_KEY_PREFIX=${{ runner.os }}/sccache/${{ inputs.platform }}/" >> $GITHUB_ENV # "SCCACHE_VERSION" is used inside Docker to install the same version of sccache echo "SCCACHE_VERSION=${{ inputs.version }}" >> $GITHUB_ENV