Skip to content

Commit 2f18567

Browse files
committed
ci: Rotate Docker cache keys every 4 weeks
This forces a periodic clean build to ensure we do not rely on stale cache layers indefinitely.
1 parent 0ffb174 commit 2f18567

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

.github/actions/run-in-docker-action/action.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ inputs:
66
required: true
77
scope:
88
description: 'A cached image scope'
9-
required: false
10-
default: ${{ runner.arch }}
9+
required: true
1110
command:
1211
description: 'A command to run in a container'
1312
required: true

.github/workflows/ci.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ jobs:
4848
docker_cache:
4949
name: "Build ${{ matrix.arch }} Docker image"
5050
runs-on: ${{ matrix.runner }}
51+
outputs:
52+
cache_scope: ${{ steps.cache_timestamp.outputs.period }}
5153

5254
strategy:
5355
fail-fast: false
@@ -59,6 +61,10 @@ jobs:
5961
runner: ubuntu-24.04-arm
6062

6163
steps:
64+
- name: Get cache validity period
65+
id: cache_timestamp
66+
run: echo "period=$(($(date +%V) / 4))" >> "$GITHUB_OUTPUT"
67+
6268
- name: Set up Docker Buildx
6369
uses: docker/setup-buildx-action@v3
6470
with:
@@ -70,8 +76,8 @@ jobs:
7076
uses: docker/build-push-action@v6
7177
with:
7278
file: ./ci/linux-debian.Dockerfile
73-
cache-from: type=gha,scope=${{ runner.arch }}
74-
cache-to: type=gha,scope=${{ runner.arch }},mode=min
79+
cache-from: type=gha,scope=${{ runner.arch }}-${{ steps.cache_timestamp.outputs.period }}
80+
cache-to: type=gha,scope=${{ runner.arch }}-${{ steps.cache_timestamp.outputs.period }},mode=min
7581

7682
x86_64-debian:
7783
name: "x86_64: Linux (Debian stable)"
@@ -117,6 +123,7 @@ jobs:
117123
uses: ./.github/actions/run-in-docker-action
118124
with:
119125
dockerfile: ./ci/linux-debian.Dockerfile
126+
scope: ${{ runner.arch }}-${{ needs.docker_cache.outputs.cache_scope }}
120127
command: ./ci/ci.sh
121128

122129
- &PRINT_LOGS
@@ -636,6 +643,7 @@ jobs:
636643
uses: ./.github/actions/run-in-docker-action
637644
with:
638645
dockerfile: ./ci/linux-debian.Dockerfile
646+
scope: ${{ runner.arch }}-${{ needs.docker_cache.outputs.cache_scope }}
639647
command: |
640648
g++ -Werror include/*.h
641649
clang -Werror -x c++-header include/*.h

0 commit comments

Comments
 (0)