-
Notifications
You must be signed in to change notification settings - Fork 72
102 lines (95 loc) · 3.11 KB
/
reuseable-builder.yml
File metadata and controls
102 lines (95 loc) · 3.11 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
name: Reusable builder
on:
workflow_call:
inputs:
target:
description: Target name
required: true
type: string
architectures:
description: List of architectures to build
required: true
type: string
version:
description: Version to build
required: true
type: string
python:
description: Python version to build
type: string
release_name:
description: Release name
required: true
type: string
version_from:
description: Version to build image from
type: string
tag_latest:
description: Tag to mark docker image as latest
required: true
type: string
python_latest:
description: Python tag to mark docker image as latest
type: string
jobs:
build:
name: Build ${{ matrix.arch }} base image
runs-on: ${{ matrix.os }}
permissions:
contents: read
id-token: write
packages: write
strategy:
fail-fast: false
matrix:
arch: ${{ fromJson(inputs.architectures) }}
include:
- os: ubuntu-24.04
- arch: aarch64
os: ubuntu-24.04-arm
steps:
- name: Checkout the repository
uses: actions/checkout@v6.0.2
- name: Login to GitHub Container Registry
if: github.event_name == 'release'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set build arguments
shell: bash
run: |
if [[ "${{ github.event_name }}" == "release" ]]; then
if [[ -n "${{ inputs.python }}" ]]; then
BUILD_ARGS="--additional-tag ${{ inputs.python }}-alpine${{ inputs.version }}-${{ github.event.release.tag_name }}"
else
BUILD_ARGS="--additional-tag ${{ inputs.version }}-${{ github.event.release.tag_name }}"
fi
if [[ "${{ inputs.tag_latest }}" != "${{ inputs.version }}" ]] \
|| [[ -n "${{ inputs.python }}" && "${{ inputs.python_latest }}" != "${{ inputs.python }}" ]];
then
BUILD_ARGS="$BUILD_ARGS --no-latest"
fi
else
BUILD_ARGS="--test"
fi
if [[ -n "${{ inputs.version_from }}" ]]; then
BUILD_ARGS="$BUILD_ARGS --version-from ${{ inputs.version_from }}"
fi
if [[ -n "${{ inputs.python }}" ]]; then
BUILD_ARGS="$BUILD_ARGS --version ${{ inputs.python }} --base ${{ inputs.python }}-alpine${{ inputs.version }}"
else
BUILD_ARGS="$BUILD_ARGS --base ${{ inputs.version }}"
fi
echo "BUILD_ARGS=$BUILD_ARGS" >> $GITHUB_ENV
- name: Build base image
uses: home-assistant/builder@2026.02.1
with:
image: ${{ matrix.arch }}
args: |
$BUILD_ARGS \
--${{ matrix.arch }} \
--target /data/${{ inputs.target }} \
--cosign \
--release ${{ inputs.release_name }} \