-
Notifications
You must be signed in to change notification settings - Fork 74
166 lines (161 loc) · 5.6 KB
/
Copy pathbuild-base-image.yml
File metadata and controls
166 lines (161 loc) · 5.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
name: Reusable workflow building a multi-arch image
on:
workflow_call:
inputs:
architectures:
description: Architectures to build (JSON array, e.g., '["amd64", "aarch64"]')
required: true
type: string
build-args:
description: Additional build arguments (key=value format, one per line)
required: false
default: ""
type: string
cache-gha:
description: Whether to use GitHub Actions cache for build caching
required: false
default: true
type: boolean
cache-gha-scope:
description: Scope for build cache sharing (defaults to architecture, set if building multiple images from a single repo)
required: false
default: ""
type: string
cache-image-tag:
description: Tag of the image containing BuildKit inline cache metadata
required: false
default: "latest"
type: string
context:
description: Build context path (usually the directory with Dockerfile)
required: true
type: string
cosign:
description: Whether to sign images with Cosign
required: false
default: true
type: boolean
cosign-base-identity:
description: Certificate identity regexp for verifying the base (FROM) image
required: false
default: ""
type: string
cosign-base-issuer:
description: Certificate OIDC issuer regexp for base image verification (defaults to cosign-issuer)
required: false
default: ""
type: string
cosign-base-verify:
description: Base image reference to verify with cosign before building
required: false
default: ""
type: string
cosign-identity:
description: Certificate identity regexp for verifying cache images (defaults to current repo pattern)
required: false
default: ""
type: string
cosign-issuer:
description: Certificate OIDC issuer regexp for all cosign verification
required: false
default: "https://token.actions.githubusercontent.com"
type: string
file:
description: Dockerfile path (defaults to "Dockerfile" in the context directory)
required: false
default: ""
type: string
image-name:
description: Image name without a tag (e.g., "base-python")
required: true
type: string
image-tags:
description: Image tags, one per line
required: true
type: string
labels:
description: Additional OCI labels (key=value format, one per line)
required: false
default: ""
type: string
push:
description: Whether to push images to registry
required: false
default: false
type: boolean
version:
description: Image version label
required: true
type: string
jobs:
prepare:
name: Prepare build matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.prepare.outputs.matrix }}
steps:
- name: Prepare multi-arch matrix
id: prepare
uses: home-assistant/builder/actions/prepare-multi-arch-matrix@62a1597b84b3461abad9816d9cd92862a2b542c3 # 2026.03.2
with:
architectures: ${{ inputs.architectures }}
image-name: ${{ inputs.image-name }}
build:
name: Build ${{ matrix.arch }} image
needs: prepare
runs-on: ${{ matrix.os }}
permissions:
contents: read
id-token: write
packages: write
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.prepare.outputs.matrix) }}
steps:
- name: Checkout the repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Build image
id: build
uses: home-assistant/builder/actions/build-image@62a1597b84b3461abad9816d9cd92862a2b542c3 # 2026.03.2
with:
arch: ${{ matrix.arch }}
build-args: ${{ inputs.build-args }}
cache-gha: ${{ inputs.cache-gha }}
cache-gha-scope: ${{ inputs.cache-gha-scope }}
cache-image-tag: ${{ inputs.cache-image-tag }}
container-registry-password: ${{ secrets.GITHUB_TOKEN }}
context: ${{ inputs.context }}
cosign: ${{ inputs.cosign }}
cosign-base-identity: ${{ inputs.cosign-base-identity }}
cosign-base-issuer: ${{ inputs.cosign-base-issuer }}
cosign-base-verify: ${{ inputs.cosign-base-verify }}
cosign-identity: ${{ inputs.cosign-identity }}
cosign-issuer: ${{ inputs.cosign-issuer }}
file: ${{ inputs.file }}
image: ${{ matrix.image }}
image-tags: ${{ inputs.image-tags }}
labels: |
io.hass.base.arch=${{ matrix.arch }}
io.hass.base.version=${{ inputs.version }}
${{ inputs.labels }}
push: ${{ inputs.push }}
version: ${{ inputs.version }}
manifest:
name: Publish multi-arch manifest
if: inputs.push
needs: [prepare, build]
runs-on: ubuntu-latest
permissions:
id-token: write
packages: write
steps:
- name: Publish multi-arch manifest
uses: home-assistant/builder/actions/publish-multi-arch-manifest@62a1597b84b3461abad9816d9cd92862a2b542c3 # 2026.03.2
with:
architectures: ${{ inputs.architectures }}
container-registry-password: ${{ secrets.GITHUB_TOKEN }}
cosign: ${{ inputs.cosign }}
image-name: ${{ inputs.image-name }}
image-tags: ${{ inputs.image-tags }}