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.
This commit is contained in:
Hennadii Stepanov
2026-02-02 11:17:18 +00:00
parent 0ffb1749a5
commit 2f18567d24
2 changed files with 11 additions and 4 deletions

View File

@@ -6,8 +6,7 @@ inputs:
required: true required: true
scope: scope:
description: 'A cached image scope' description: 'A cached image scope'
required: false required: true
default: ${{ runner.arch }}
command: command:
description: 'A command to run in a container' description: 'A command to run in a container'
required: true required: true

View File

@@ -48,6 +48,8 @@ jobs:
docker_cache: docker_cache:
name: "Build ${{ matrix.arch }} Docker image" name: "Build ${{ matrix.arch }} Docker image"
runs-on: ${{ matrix.runner }} runs-on: ${{ matrix.runner }}
outputs:
cache_scope: ${{ steps.cache_timestamp.outputs.period }}
strategy: strategy:
fail-fast: false fail-fast: false
@@ -59,6 +61,10 @@ jobs:
runner: ubuntu-24.04-arm runner: ubuntu-24.04-arm
steps: steps:
- name: Get cache validity period
id: cache_timestamp
run: echo "period=$(($(date +%V) / 4))" >> "$GITHUB_OUTPUT"
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
with: with:
@@ -70,8 +76,8 @@ jobs:
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
file: ./ci/linux-debian.Dockerfile file: ./ci/linux-debian.Dockerfile
cache-from: type=gha,scope=${{ runner.arch }} cache-from: type=gha,scope=${{ runner.arch }}-${{ steps.cache_timestamp.outputs.period }}
cache-to: type=gha,scope=${{ runner.arch }},mode=min cache-to: type=gha,scope=${{ runner.arch }}-${{ steps.cache_timestamp.outputs.period }},mode=min
x86_64-debian: x86_64-debian:
name: "x86_64: Linux (Debian stable)" name: "x86_64: Linux (Debian stable)"
@@ -117,6 +123,7 @@ jobs:
uses: ./.github/actions/run-in-docker-action uses: ./.github/actions/run-in-docker-action
with: with:
dockerfile: ./ci/linux-debian.Dockerfile dockerfile: ./ci/linux-debian.Dockerfile
scope: ${{ runner.arch }}-${{ needs.docker_cache.outputs.cache_scope }}
command: ./ci/ci.sh command: ./ci/ci.sh
- &PRINT_LOGS - &PRINT_LOGS
@@ -636,6 +643,7 @@ jobs:
uses: ./.github/actions/run-in-docker-action uses: ./.github/actions/run-in-docker-action
with: with:
dockerfile: ./ci/linux-debian.Dockerfile dockerfile: ./ci/linux-debian.Dockerfile
scope: ${{ runner.arch }}-${{ needs.docker_cache.outputs.cache_scope }}
command: | command: |
g++ -Werror include/*.h g++ -Werror include/*.h
clang -Werror -x c++-header include/*.h clang -Werror -x c++-header include/*.h