ci: reuse docker images across jobs

We were rebuilding Docker images from scratch with --no-cache, tagged by PR
number. With this, we were building multiple images per PR for the same
context.

This change tags the images by the git tree hash of the build context and only
build if the tag is missing. This naturally covers rebuilding on build context
changes.

Finally, this change handles refreshing images every 7 days (for example to
refresh OS packages) and prune by CI label after 14 days. The gap ensures an
image a running job just picked up isn't pruned under it.

Signed-off-by: Andrei Gherzan <andrei@gherzan.com>
This commit is contained in:
Andrei Gherzan committed 2026-10-19 04:47:45 +01:00
1 parent 26ddb68f93
commit df3c09e34c
6 files changed
+63 -55

No files matched your search

+5 -7
View File
@@ -22,24 +22,22 @@ jobs:
- name: Check for Yocto relevant changes
id: changed-files-specific
uses: ./.github/actions/changed-files
- name: Build a temporary yocto-builder image
- name: Build the yocto-builder image
id: docker
uses: ./.github/actions/docker-build
with:
docker_image: yocto-builder
id: ${{ github.event.number }}
if: steps.changed-files-specific.outputs.any_changed == 'true'
- name: Run yocto-check-layer
run: |
docker run --rm --security-opt apparmor=unconfined \
-v "$GITHUB_WORKSPACE:/work:ro" \
--env "BASE_REF=$GITHUB_BASE_REF" \
"yocto-builder-${{ github.event.number }}" \
"${{ steps.docker.outputs.image }}" \
/entrypoint-yocto-check-layer.sh
if: steps.changed-files-specific.outputs.any_changed == 'true'
- name: Cleanup temporary docker image
uses: ./.github/actions/docker-clean-image
with:
docker_image: yocto-builder-${{ github.event.number }}
- name: Prune old CI docker images
uses: ./.github/actions/docker-prune-images
if: always()
- name: Cleanup dangling docker images
uses: ./.github/actions/docker-clean-dangling