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
31
+ push :
32
+ description : Whether to push images
33
+ type : boolean
34
+ required : false
35
+ default : true
29
36
30
37
env :
31
38
ANSIBLE_FORCE_COLOR : True
32
39
jobs :
40
+ generate-tag :
41
+ name : Generate container image tag
42
+ if : github.repository == 'stackhpc/stackhpc-kayobe-config'
43
+ runs-on : [self-hosted, stackhpc-kayobe-config-kolla-builder]
44
+ permissions : {}
45
+ outputs :
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 }}
49
+ steps :
50
+ - name : Checkout
51
+ uses : actions/checkout@v3
52
+
53
+ - name : Determine OpenStack release
54
+ id : openstack_release
55
+ run : |
56
+ BRANCH=$(awk -F'=' '/defaultbranch/ {print $2}' .gitreview)
57
+ echo "openstack_release=${BRANCH}" | sed "s|stable/||" >> $GITHUB_OUTPUT
58
+
59
+ # Generate a tag to apply to all built container images.
60
+ # Without this, each kayobe * container image build command would use a different tag.
61
+ - name : Generate container image tag
62
+ id : kolla_tag
63
+ run : |
64
+ echo "kolla_tag=$(date +${{ steps.openstack_release.outputs.openstack_release }}-%Y%m%dT%H%M%S)" >> $GITHUB_OUTPUT
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
+
84
+ - name : Display container image tag
85
+ run : |
86
+ echo "${{ steps.kolla_tag.outputs.kolla_tag }}"
87
+
33
88
container-image-build :
34
89
name : Build Kolla container images
35
90
if : github.repository == 'stackhpc/stackhpc-kayobe-config'
36
91
runs-on : [self-hosted, stackhpc-kayobe-config-kolla-builder]
92
+ permissions : {}
93
+ strategy :
94
+ matrix : ${{ fromJson(needs.generate-tag.outputs.matrix) }}
95
+ needs :
96
+ - generate-tag
37
97
steps :
38
98
- uses : actions/checkout@v3
39
99
with :
43
103
uses : actions/checkout@v3
44
104
with :
45
105
repository : stackhpc/kayobe
46
- ref : refs/heads/stackhpc/wallaby
106
+ ref : refs/heads/stackhpc/${{ needs.generate-tag.outputs.openstack_release }}
47
107
path : src/kayobe
48
108
49
109
# FIXME: Failed in kolla-ansible : Ensure the latest version of pip is installed
@@ -99,57 +159,43 @@ jobs:
99
159
100
160
- name : Build and push kolla overcloud images
101
161
run : |
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 }}"
165
+ if ${{ inputs.push }} == 'true'; then
166
+ args="$args --push"
167
+ fi
102
168
source venvs/kayobe/bin/activate &&
103
169
source src/kayobe-config/kayobe-env --environment ci-builder &&
104
- kayobe overcloud container image build ${{ github.event.inputs.regexes }} --push -e kolla_base_distro=${{ inputs.distro }}
170
+ kayobe overcloud container image build $args
105
171
env :
106
172
KAYOBE_VAULT_PASSWORD : ${{ secrets.KAYOBE_VAULT_PASSWORD }}
107
173
if : github.event.inputs.overcloud == 'true'
108
174
109
- - name : Display the overcloud container image tag
110
- run : |
111
- echo "$(cat ~/kolla_tag)"
112
- if : github.event.inputs.overcloud == 'true'
113
-
114
- - name : Get built overcloud container images
115
- run : |
116
- sudo docker image ls --filter "reference=ark.stackhpc.com/stackhpc-dev/*:$(cat ~/kolla_tag)" > overcloud-container-images
117
- if : github.event.inputs.overcloud == 'true'
118
-
119
- - name : Upload overcloud-container-images artifact
120
- uses : actions/upload-artifact@v3
121
- with :
122
- name : Overcloud container images
123
- path : overcloud-container-images
124
- retention-days : 7
125
- if : github.event.inputs.overcloud == 'true'
126
-
127
175
- name : Build and push kolla seed images
128
176
run : |
177
+ args="kolla_base_distro=${{ matrix.distro }}"
178
+ args="$args -e kolla_tag=${{ needs.generate-tag.outputs.kolla_tag }}"
179
+ if ${{ inputs.push }} == 'true'; then
180
+ args="$args --push"
181
+ fi
129
182
source venvs/kayobe/bin/activate &&
130
183
source src/kayobe-config/kayobe-env --environment ci-builder &&
131
- kayobe seed container image build --push -e kolla_base_distro=${{ inputs.distro }}
184
+ kayobe seed container image build $args
132
185
env :
133
186
KAYOBE_VAULT_PASSWORD : ${{ secrets.KAYOBE_VAULT_PASSWORD }}
134
187
if : github.event.inputs.seed == 'true'
135
188
136
- - name : Display the seed container image tag
137
- run : |
138
- echo "$(cat ~/kolla_tag)"
139
- if : github.event.inputs.seed == 'true'
140
-
141
- - name : Get built seed container images
189
+ - name : Get built container images
142
190
run : |
143
- sudo docker image ls --filter "reference=ark.stackhpc.com/stackhpc-dev/*:$(cat ~/kolla_tag)" > seed-container-images
144
- 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
145
192
146
- - name : Upload seed- container- images artifact
193
+ - name : Upload container images artifact
147
194
uses : actions/upload-artifact@v3
148
195
with :
149
- name : Seed container images
150
- path : seed -container-images
196
+ name : ${{ matrix.distro }} container images
197
+ path : ${{ matrix.distro }} -container-images
151
198
retention-days : 7
152
- if : github.event.inputs.seed == 'true'
153
199
154
200
- name : Prune local Kolla container images over 1 week old
155
201
run : |
@@ -159,8 +205,9 @@ jobs:
159
205
name : Trigger container image repository sync
160
206
needs :
161
207
- container-image-build
162
- if : github.repository == 'stackhpc/stackhpc-kayobe-config'
208
+ if : github.repository == 'stackhpc/stackhpc-kayobe-config' && inputs.push
163
209
runs-on : ubuntu-latest
210
+ permissions : {}
164
211
steps :
165
212
# NOTE(mgoddard): Trigger another CI workflow in the
166
213
# stackhpc-release-train repository.
0 commit comments