11on :
22 workflow_dispatch :
33 inputs :
4- image :
5- default : ghcr.io/viamrobotics/cpp-base
4+ image-prefix :
5+ description : " gets suffixed with 'base' and 'sdk' to create actual image name"
6+ default : ghcr.io/viamrobotics/cpp-
67 dockerfile :
78 default : Dockerfile.debian.bullseye
89 tag :
910 default : bullseye-amd64
11+ build-base :
12+ description : " whether to build the base image. the base images change less often and may not be necessary to rebuild."
13+ type : boolean
14+ default : false
15+ build-sdk :
16+ description : " whether to build the SDK image. if this is true and no corresponding base image exists, the job will fail."
17+ type : boolean
18+ default : false
19+ push :
20+ description : " whether to push the images after building them"
21+ type : boolean
22+ default : false
1023
1124jobs :
1225 build-container :
@@ -16,14 +29,33 @@ jobs:
1629 packages : write
1730 steps :
1831 - uses : actions/checkout@v4
32+
33+ # build base (if inputs.build-base)
1934 - uses : docker/metadata-action@v5
20- id : meta
35+ id : base-meta
36+ if : inputs.build-base
2137 with :
22- images : ${{ inputs.image }}
38+ images : ${{ inputs.image-prefix }}base
2339 - uses : docker/build-push-action@v5
40+ if : inputs.build-base
2441 with :
25- context : .
26- push : true
27- tags : " ${{ inputs.image }}:${{ inputs.tag }}"
42+ push : ${{ inputs.push }}
43+ tags : " ${{ inputs.image-prefix }}base:${{ inputs.tag }}"
2844 file : etc/docker/base-images/${{ inputs.dockerfile }}
29- labels : ${{ steps.meta.output.labels }}
45+ labels : ${{ steps.base-meta.output.labels }}
46+
47+ # build sdk (if inputs.build-sdk)
48+ - uses : docker/metadata-action@v5
49+ id : sdk-meta
50+ if : inputs.build-sdk
51+ with :
52+ images : ${{ inputs.image-prefix }}sdk
53+ - uses : docker/build-push-action@v5
54+ if : inputs.build-sdk
55+ with :
56+ build-args : |
57+ BASE_TAG=${{ inputs.image-prefix }}base:${{ inputs.tag }}
58+ push : ${{ inputs.push }}
59+ tags : " ${{ inputs.image-prefix }}sdk:${{ inputs.tag }}"
60+ file : etc/docker/Dockerfile.sdk-build
61+ labels : ${{ steps.sdk-meta.output.labels }}
0 commit comments