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]
37
92
timeout-minutes : 720
93
+ permissions : {}
94
+ strategy :
95
+ matrix : ${{ fromJson(needs.generate-tag.outputs.matrix) }}
96
+ needs :
97
+ - generate-tag
38
98
steps :
39
99
- uses : actions/checkout@v3
40
100
with :
44
104
uses : actions/checkout@v3
45
105
with :
46
106
repository : stackhpc/kayobe
47
- ref : refs/heads/stackhpc/xena
107
+ ref : refs/heads/stackhpc/${{ needs.generate-tag.outputs.openstack_release }}
48
108
path : src/kayobe
49
109
50
110
# FIXME: Failed in kolla-ansible : Ensure the latest version of pip is installed
@@ -100,57 +160,43 @@ jobs:
100
160
101
161
- name : Build and push kolla overcloud images
102
162
run : |
163
+ args="${{ github.event.inputs.regexes }}"
164
+ args="$args -e kolla_base_distro=${{ matrix.distro }}"
165
+ args="$args -e kolla_tag=${{ needs.generate-tag.outputs.kolla_tag }}"
166
+ if ${{ inputs.push }} == 'true'; then
167
+ args="$args --push"
168
+ fi
103
169
source venvs/kayobe/bin/activate &&
104
170
source src/kayobe-config/kayobe-env --environment ci-builder &&
105
- kayobe overcloud container image build ${{ github.event.inputs.regexes }} --push -e kolla_base_distro=${{ inputs.distro }}
171
+ kayobe overcloud container image build $args
106
172
env :
107
173
KAYOBE_VAULT_PASSWORD : ${{ secrets.KAYOBE_VAULT_PASSWORD }}
108
174
if : github.event.inputs.overcloud == 'true'
109
175
110
- - name : Display the overcloud container image tag
111
- run : |
112
- echo "$(cat ~/kolla_tag)"
113
- if : github.event.inputs.overcloud == 'true'
114
-
115
- - name : Get built overcloud container images
116
- run : |
117
- sudo docker image ls --filter "reference=ark.stackhpc.com/stackhpc-dev/*:$(cat ~/kolla_tag)" > overcloud-container-images
118
- if : github.event.inputs.overcloud == 'true'
119
-
120
- - name : Upload overcloud-container-images artifact
121
- uses : actions/upload-artifact@v3
122
- with :
123
- name : Overcloud container images
124
- path : overcloud-container-images
125
- retention-days : 7
126
- if : github.event.inputs.overcloud == 'true'
127
-
128
176
- name : Build and push kolla seed images
129
177
run : |
178
+ args="kolla_base_distro=${{ matrix.distro }}"
179
+ args="$args -e kolla_tag=${{ needs.generate-tag.outputs.kolla_tag }}"
180
+ if ${{ inputs.push }} == 'true'; then
181
+ args="$args --push"
182
+ fi
130
183
source venvs/kayobe/bin/activate &&
131
184
source src/kayobe-config/kayobe-env --environment ci-builder &&
132
- kayobe seed container image build --push -e kolla_base_distro=${{ inputs.distro }}
185
+ kayobe seed container image build $args
133
186
env :
134
187
KAYOBE_VAULT_PASSWORD : ${{ secrets.KAYOBE_VAULT_PASSWORD }}
135
188
if : github.event.inputs.seed == 'true'
136
189
137
- - name : Display the seed container image tag
138
- run : |
139
- echo "$(cat ~/kolla_tag)"
140
- if : github.event.inputs.seed == 'true'
141
-
142
- - name : Get built seed container images
190
+ - name : Get built container images
143
191
run : |
144
- sudo docker image ls --filter "reference=ark.stackhpc.com/stackhpc-dev/*:$(cat ~/kolla_tag)" > seed-container-images
145
- if : github.event.inputs.seed == 'true'
192
+ sudo docker image ls --filter "reference=ark.stackhpc.com/stackhpc-dev/${{ matrix.distro }}-*:${{ needs.generate-tag.outputs.kolla_tag }}" > ${{ matrix.distro }}-container-images
146
193
147
- - name : Upload seed- container- images artifact
194
+ - name : Upload container images artifact
148
195
uses : actions/upload-artifact@v3
149
196
with :
150
- name : Seed container images
151
- path : seed -container-images
197
+ name : ${{ matrix.distro }} container images
198
+ path : ${{ matrix.distro }} -container-images
152
199
retention-days : 7
153
- if : github.event.inputs.seed == 'true'
154
200
155
201
- name : Prune local Kolla container images over 1 week old
156
202
run : |
@@ -160,8 +206,9 @@ jobs:
160
206
name : Trigger container image repository sync
161
207
needs :
162
208
- container-image-build
163
- if : github.repository == 'stackhpc/stackhpc-kayobe-config'
209
+ if : github.repository == 'stackhpc/stackhpc-kayobe-config' && inputs.push
164
210
runs-on : ubuntu-latest
211
+ permissions : {}
165
212
steps :
166
213
# NOTE(mgoddard): Trigger another CI workflow in the
167
214
# stackhpc-release-train repository.
0 commit comments