1
+ # NB: When run via workflow_dispatch, image scanning and distribution to other clouds does not happen
2
+ # on the basis that in this case a fatimage must be built and will be scanned.
1
3
name : Build nightly image
2
4
on :
3
5
workflow_dispatch :
14
16
- cron : ' 0 0 * * *' # Run at midnight
15
17
16
18
jobs :
17
- openstack :
18
- name : openstack -imagebuild
19
+ build :
20
+ name : nightly -imagebuild
19
21
concurrency :
20
22
group : ${{ github.workflow }}-${{ github.ref }}-${{ matrix.builds.label }}
21
23
cancel-in-progress : true
37
39
ANSIBLE_FORCE_COLOR : True
38
40
OS_CLOUD : openstack
39
41
CI_CLOUD : ${{ github.event.inputs.ci_cloud || vars.CI_CLOUD }}
40
- # set the image suffix to -latest for cron jobs or a branch name if manually-triggered
41
- IMAGE_SUFFIX : ${{ github.event_name == 'schedule' && 'latest' || github.ref_name }}
42
+ IMAGE_VERSION : ${{ github.event_name == 'schedule' && 'latest' || github.ref_name }}
42
43
43
44
steps :
44
45
- uses : actions/checkout@v2
87
88
-var-file=$PKR_VAR_environment_root/${{ env.CI_CLOUD }}.pkrvars.hcl \
88
89
-var source_image_name=${{ matrix.builds.source_image_name }} \
89
90
-var image_name=${{ matrix.builds.label }} \
90
- -var image_version=${{ env.IMAGE_SUFFIX }} \
91
+ -var image_version=${{ env.IMAGE_VERSION }} \
91
92
-var inventory_groups=${{ matrix.builds.inventory_groups }} \
92
93
openstack.pkr.hcl
93
94
env :
@@ -102,10 +103,12 @@ jobs:
102
103
sleep 5
103
104
done
104
105
IMAGE_NAME=$(openstack image show -f value -c name $IMAGE_ID)
106
+ echo image: ${IMAGE_NAME} ${IMAGE_ID}
105
107
echo "image-name=${IMAGE_NAME}" >> "$GITHUB_OUTPUT"
106
108
echo "image-id=$IMAGE_ID" >> "$GITHUB_OUTPUT"
107
109
108
110
- name : Download image
111
+ if : github.event_name == 'schedule'
109
112
run : |
110
113
. venv/bin/activate
111
114
sudo mkdir /mnt/images
@@ -114,20 +117,23 @@ jobs:
114
117
openstack image save --file /mnt/images/${{ steps.manifest.outputs.image-name }}.qcow2 ${{ steps.manifest.outputs.image-id }}
115
118
116
119
- name : Set up QEMU
120
+ if : github.event_name == 'schedule'
117
121
uses : docker/setup-qemu-action@v3
118
122
119
- - name : install libguestfs
123
+ - name : Install libguestfs
120
124
run : |
121
125
sudo apt -y update
122
126
sudo apt -y install libguestfs-tools
127
+ if : github.event_name == 'schedule'
123
128
124
- - name : mkdir for mount
125
- run : sudo mkdir -p './${{ steps.manifest.outputs.image-name }} '
126
-
127
- - name : mount qcow2 file
128
- run : sudo guestmount -a /mnt/images/${{ steps.manifest.outputs.image-name }}.qcow2 -i --ro -o allow_other './${{ steps.manifest.outputs.image-name }}'
129
-
129
+ - name : Mount image
130
+ if : github.event_name == 'schedule '
131
+ run : |
132
+ sudo mkdir -p './${{ steps.manifest.outputs.image-name }}'
133
+ sudo guestmount -a /mnt/images/${{ steps.manifest.outputs.image-name }}.qcow2 -i --ro -o allow_other './${{ steps.manifest.outputs.image-name }}'
134
+
130
135
- name : Run Trivy vulnerability scanner
136
+ if : github.event_name == 'schedule'
131
137
uses :
aquasecurity/[email protected]
132
138
with :
133
139
scan-type : fs
@@ -140,12 +146,14 @@ jobs:
140
146
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
141
147
142
148
- name : Upload Trivy scan results to GitHub Security tab
149
+ if : github.event_name == 'schedule'
143
150
uses : github/codeql-action/upload-sarif@v3
144
151
with :
145
152
sarif_file : " ${{ steps.manifest.outputs.image-name }}.sarif"
146
- category : " ${{ matrix.os_version }}-${{ matrix. build }}"
153
+ category : " ${{ matrix.build.label }}"
147
154
148
155
- name : Fail if scan has CRITICAL vulnerabilities
156
+ if : github.event_name == 'schedule'
149
157
uses :
aquasecurity/[email protected]
150
158
with :
151
159
scan-type : fs
@@ -157,16 +165,17 @@ jobs:
157
165
ignore-unfixed : true
158
166
env :
159
167
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
168
+
160
169
161
170
- name : Delete new image if Trivy scan fails
162
- if : failure() && steps.packer_build.outcome == 'success' # Runs if the Trivy scan found crit vulnerabilities or failed
171
+ if : github.event_name == 'schedule' && failure() && steps.packer_build.outcome == 'success' # Runs if the Trivy scan found crit vulnerabilities or failed
163
172
run : |
164
173
. venv/bin/activate
165
174
echo "Deleting new image due to critical vulnerabilities or scan failure ..."
166
175
openstack image delete "${{ steps.manifest.outputs.image-id }}"
167
176
168
- - name : Delete old latest image
169
- if : success() # Runs only if Trivy scan passed
177
+ - name : Delete old image
178
+ if : github.event_name == 'schedule'
170
179
run : |
171
180
. venv/bin/activate
172
181
IMAGE_COUNT=$(openstack image list --name ${{ steps.manifest.outputs.image-name }} -f value -c ID | wc -l)
@@ -180,9 +189,10 @@ jobs:
180
189
181
190
upload :
182
191
name : upload-nightly-targets
183
- needs : openstack
192
+ needs : build
193
+ if : github.event_name == 'schedule'
184
194
concurrency :
185
- group : ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os_version }}-${{ matrix.image }}-${{ matrix.target_cloud }}
195
+ group : ${{ github.workflow }}-${{ github.ref }}-${{ matrix.builds.label }}-${{ matrix.target_cloud }}
186
196
cancel-in-progress : true
187
197
runs-on : ubuntu-22.04
188
198
strategy :
@@ -192,21 +202,16 @@ jobs:
192
202
- LEAFCLOUD
193
203
- SMS
194
204
- ARCUS
195
- os_version :
196
- - RL8
197
- - RL9
198
- image :
199
- - rocky-latest
200
- - rocky-latest-cuda
205
+ builds :
206
+ - image : RL8-ofed-latest
207
+ - image : RL9-ofed-latest
208
+ - image : RL9-cuda-latest
201
209
exclude :
202
- - os_version : RL8
203
- image : rocky-latest-cuda
204
- - target_cloud : LEAFCLOUD
210
+ - target_cloud : LEAFCLOUD # why?? Should this not be source_cloud/vars.CI_CLOUD
205
211
env :
206
212
OS_CLOUD : openstack
207
213
SOURCE_CLOUD : ${{ github.event.inputs.ci_cloud || vars.CI_CLOUD }}
208
214
TARGET_CLOUD : ${{ matrix.target_cloud }}
209
- IMAGE_NAME : " ${{ matrix.image }}-${{ matrix.os_version }}"
210
215
steps :
211
216
- uses : actions/checkout@v2
212
217
@@ -234,16 +239,16 @@ jobs:
234
239
run : |
235
240
. venv/bin/activate
236
241
export OS_CLIENT_CONFIG_FILE=~/.config/openstack/source_clouds.yaml
237
- openstack image save --file ${{ env.IMAGE_NAME }} ${{ env.IMAGE_NAME }}
242
+ openstack image save --file ${{ matrix.builds.image }} ${{ matrix.builds.image }}
238
243
shell : bash
239
244
240
245
- name : Upload to target cloud
241
246
run : |
242
247
. venv/bin/activate
243
248
export OS_CLIENT_CONFIG_FILE=~/.config/openstack/target_clouds.yaml
244
249
245
- openstack image create "${{ env.IMAGE_NAME }}" \
246
- --file "${{ env.IMAGE_NAME }}" \
250
+ openstack image create "${{ matrix.builds.image }}" \
251
+ --file "${{ matrix.builds.image }}" \
247
252
--disk-format qcow2 \
248
253
shell : bash
249
254
@@ -252,9 +257,9 @@ jobs:
252
257
. venv/bin/activate
253
258
export OS_CLIENT_CONFIG_FILE=~/.config/openstack/target_clouds.yaml
254
259
255
- IMAGE_COUNT=$(openstack image list --name ${{ env.IMAGE_NAME }} -f value -c ID | wc -l)
260
+ IMAGE_COUNT=$(openstack image list --name ${{ matrix.builds.image }} -f value -c ID | wc -l)
256
261
if [ "$IMAGE_COUNT" -gt 1 ]; then
257
- OLD_IMAGE_ID=$(openstack image list --sort created_at:asc --name "${{ env.IMAGE_NAME }}" -f value -c ID | head -n 1)
262
+ OLD_IMAGE_ID=$(openstack image list --sort created_at:asc --name "${{ matrix.builds.image }}" -f value -c ID | head -n 1)
258
263
openstack image delete "$OLD_IMAGE_ID"
259
264
else
260
265
echo "Only one image exists, skipping deletion."
0 commit comments