18
18
type : boolean
19
19
required : false
20
20
default : false
21
- distro :
22
- description : Container image OS distribution
23
- type : choice
21
+ centos-stream-8 :
22
+ description : Build CentOS Stream 8 images?
23
+ type : boolean
24
+ required : false
25
+ default : true
26
+ ubuntu-focal :
27
+ description : Build Ubuntu Focal 20.04 images?
28
+ type : boolean
24
29
required : false
25
- default : centos
26
- options :
27
- - centos
28
- - ubuntu
30
+ default : true
29
31
push :
30
32
description : Whether to push images
31
33
type : boolean
41
43
runs-on : [self-hosted, stackhpc-kayobe-config-kolla-builder]
42
44
permissions : {}
43
45
outputs :
44
- openstack_release : ${{ steps.openstack_release.outputs.openstack_release }}
45
46
kolla_tag : ${{ steps.kolla_tag.outputs.kolla_tag }}
47
+ matrix : ${{ steps.set-matrix.outputs.matrix }}
48
+ openstack_release : ${{ steps.openstack_release.outputs.openstack_release }}
46
49
steps :
47
50
- name : Checkout
48
51
uses : actions/checkout@v3
60
63
run : |
61
64
echo "kolla_tag=$(date +${{ steps.openstack_release.outputs.openstack_release }}-%Y%m%dT%H%M%S)" >> $GITHUB_OUTPUT
62
65
66
+ # Dynamically define job matrix.
67
+ # We need a separate matrix entry for each distribution, when the relevant input is true.
68
+ # https://stackoverflow.com/questions/65384420/how-do-i-make-a-github-action-matrix-element-conditional
69
+ - name : Generate build matrix
70
+ id : set-matrix
71
+ run : |
72
+ comma=""
73
+ echo -n "matrix={\"distro\": [" >> $GITHUB_OUTPUT
74
+ if [[ ${{ inputs.centos-stream-8 }} == 'true' ]]; then
75
+ echo -n "$comma\"centos\"" >> $GITHUB_OUTPUT
76
+ comma=", "
77
+ fi
78
+ if [[ ${{ inputs.ubuntu-focal }} == 'true' ]]; then
79
+ echo -n "$comma\"ubuntu\"" >> $GITHUB_OUTPUT
80
+ comma=", "
81
+ fi
82
+ echo "]}" >> $GITHUB_OUTPUT
83
+
63
84
- name : Display container image tag
64
85
run : |
65
86
echo "${{ steps.kolla_tag.outputs.kolla_tag }}"
69
90
if : github.repository == 'stackhpc/stackhpc-kayobe-config'
70
91
runs-on : [self-hosted, stackhpc-kayobe-config-kolla-builder]
71
92
permissions : {}
93
+ strategy :
94
+ matrix : ${{ fromJson(needs.generate-tag.outputs.matrix) }}
72
95
needs :
73
96
- generate-tag
74
97
steps :
@@ -136,7 +159,9 @@ jobs:
136
159
137
160
- name : Build and push kolla overcloud images
138
161
run : |
139
- args="${{ github.event.inputs.regexes }} -e kolla_base_distro=${{ inputs.distro }} -e kolla_tag=${{ needs.generate-tag.outputs.kolla_tag }}"
162
+ args="${{ github.event.inputs.regexes }}"
163
+ args="$args -e kolla_base_distro=${{ matrix.distro }}"
164
+ args="$args -e kolla_tag=${{ needs.generate-tag.outputs.kolla_tag }}"
140
165
if ${{ inputs.push }} == 'true'; then
141
166
args="$args --push"
142
167
fi
@@ -147,27 +172,10 @@ jobs:
147
172
KAYOBE_VAULT_PASSWORD : ${{ secrets.KAYOBE_VAULT_PASSWORD }}
148
173
if : github.event.inputs.overcloud == 'true'
149
174
150
- - name : Display the overcloud container image tag
151
- run : |
152
- echo "$(cat ~/kolla_tag)"
153
- if : github.event.inputs.overcloud == 'true'
154
-
155
- - name : Get built overcloud container images
156
- run : |
157
- sudo docker image ls --filter "reference=ark.stackhpc.com/stackhpc-dev/*:$(cat ~/kolla_tag)" > overcloud-container-images
158
- if : github.event.inputs.overcloud == 'true'
159
-
160
- - name : Upload overcloud-container-images artifact
161
- uses : actions/upload-artifact@v3
162
- with :
163
- name : Overcloud container images
164
- path : overcloud-container-images
165
- retention-days : 7
166
- if : github.event.inputs.overcloud == 'true'
167
-
168
175
- name : Build and push kolla seed images
169
176
run : |
170
- args="kolla_base_distro=${{ inputs.distro }} -e kolla_tag=${{ needs.generate-tag.outputs.kolla_tag }}"
177
+ args="kolla_base_distro=${{ matrix.distro }}"
178
+ args="$args -e kolla_tag=${{ needs.generate-tag.outputs.kolla_tag }}"
171
179
if ${{ inputs.push }} == 'true'; then
172
180
args="$args --push"
173
181
fi
@@ -178,23 +186,16 @@ jobs:
178
186
KAYOBE_VAULT_PASSWORD : ${{ secrets.KAYOBE_VAULT_PASSWORD }}
179
187
if : github.event.inputs.seed == 'true'
180
188
181
- - name : Display the seed container image tag
182
- run : |
183
- echo "$(cat ~/kolla_tag)"
184
- if : github.event.inputs.seed == 'true'
185
-
186
- - name : Get built seed container images
189
+ - name : Get built container images
187
190
run : |
188
- sudo docker image ls --filter "reference=ark.stackhpc.com/stackhpc-dev/*:$(cat ~/kolla_tag)" > seed-container-images
189
- if : github.event.inputs.seed == 'true'
191
+ sudo docker image ls --filter "reference=ark.stackhpc.com/stackhpc-dev/${{ matrix.distro }}-*:${{ needs.generate-tag.outputs.kolla_tag }}" > ${{ matrix.distro }}-container-images
190
192
191
- - name : Upload seed- container- images artifact
193
+ - name : Upload container images artifact
192
194
uses : actions/upload-artifact@v3
193
195
with :
194
- name : Seed container images
195
- path : seed -container-images
196
+ name : ${{ matrix.distro }} container images
197
+ path : ${{ matrix.distro }} -container-images
196
198
retention-days : 7
197
- if : github.event.inputs.seed == 'true'
198
199
199
200
- name : Prune local Kolla container images over 1 week old
200
201
run : |
0 commit comments