1818 type : boolean
1919 required : false
2020 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
2429 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
2936
3037env :
3138 ANSIBLE_FORCE_COLOR : True
3239jobs :
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+
3388 container-image-build :
3489 name : Build Kolla container images
3590 if : github.repository == 'stackhpc/stackhpc-kayobe-config'
3691 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
3797 steps :
3898 - uses : actions/checkout@v3
3999 with :
43103 uses : actions/checkout@v3
44104 with :
45105 repository : stackhpc/kayobe
46- ref : refs/heads/stackhpc/wallaby
106+ ref : refs/heads/stackhpc/${{ needs.generate-tag.outputs.openstack_release }}
47107 path : src/kayobe
48108
49109 # FIXME: Failed in kolla-ansible : Ensure the latest version of pip is installed
@@ -99,57 +159,43 @@ jobs:
99159
100160 - name : Build and push kolla overcloud images
101161 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
102168 source venvs/kayobe/bin/activate &&
103169 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
105171 env :
106172 KAYOBE_VAULT_PASSWORD : ${{ secrets.KAYOBE_VAULT_PASSWORD }}
107173 if : github.event.inputs.overcloud == 'true'
108174
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-
127175 - name : Build and push kolla seed images
128176 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
129182 source venvs/kayobe/bin/activate &&
130183 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
132185 env :
133186 KAYOBE_VAULT_PASSWORD : ${{ secrets.KAYOBE_VAULT_PASSWORD }}
134187 if : github.event.inputs.seed == 'true'
135188
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
142190 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
145192
146- - name : Upload seed- container- images artifact
193+ - name : Upload container images artifact
147194 uses : actions/upload-artifact@v3
148195 with :
149- name : Seed container images
150- path : seed -container-images
196+ name : ${{ matrix.distro }} container images
197+ path : ${{ matrix.distro }} -container-images
151198 retention-days : 7
152- if : github.event.inputs.seed == 'true'
153199
154200 - name : Prune local Kolla container images over 1 week old
155201 run : |
@@ -159,8 +205,9 @@ jobs:
159205 name : Trigger container image repository sync
160206 needs :
161207 - container-image-build
162- if : github.repository == 'stackhpc/stackhpc-kayobe-config'
208+ if : github.repository == 'stackhpc/stackhpc-kayobe-config' && inputs.push
163209 runs-on : ubuntu-latest
210+ permissions : {}
164211 steps :
165212 # NOTE(mgoddard): Trigger another CI workflow in the
166213 # stackhpc-release-train repository.
0 commit comments