Skip to content

Commit d3e9212

Browse files
authored
fix: Bypass Docker layer cache when rebuilding for OS patches (#609)
1 parent 377a1f9 commit d3e9212

3 files changed

Lines changed: 24 additions & 0 deletions

File tree

.github/workflows/_build-and-push.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@ on:
4545
type: string
4646
required: false
4747
default: ""
48+
no_cache:
49+
description: >-
50+
Build without layer cache. Required when the goal is picking up OS
51+
package patches: the `microdnf update` layer is keyed on the base
52+
image digest, so cached builds silently skip repo updates (e.g.
53+
AL2023 security patches) published since the layer was first built.
54+
type: boolean
55+
required: false
56+
default: false
4857

4958
permissions:
5059
contents: read
@@ -110,6 +119,7 @@ jobs:
110119
provenance: false
111120
tags: ${{ steps.meta.outputs.tags }}
112121
labels: ${{ steps.meta.outputs.labels }}
122+
no-cache: ${{ inputs.no_cache }}
113123
cache-from: type=gha
114124
cache-to: type=gha,mode=max
115125
secrets: |

.github/workflows/docker-image-push.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ on:
1818
version_tag:
1919
description: Optional Docker tag
2020
required: false
21+
no_cache:
22+
description: >-
23+
Build without layer cache so OS package patches are picked up.
24+
Disable only when rebuilding for a code change.
25+
type: boolean
26+
required: false
27+
default: true
2128

2229
permissions:
2330
contents: read
@@ -56,3 +63,7 @@ jobs:
5663
extra_tag: ${{ github.event.inputs.version_tag || '' }}
5764
tag_branch: true
5865
tag_latest: ${{ github.ref_name == 'main' }}
66+
# The weekly rebuild exists to pick up base-image/OS patches, which a
67+
# cached `microdnf update` layer silently skips — so bust the cache on
68+
# schedule and (by default) on manual dispatch. Push builds stay cached.
69+
no_cache: ${{ github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && github.event.inputs.no_cache != 'false') }}

.github/workflows/release.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ jobs:
7272
major_tag: ${{ needs.detect-release.outputs.major }}
7373
tag_latest: true
7474
tag_branch: false
75+
# Versioned images are long-lived; never bake week-old cached OS layers
76+
# into a release.
77+
no_cache: true
7578

7679
release:
7780
needs: [detect-release, build]

0 commit comments

Comments
 (0)