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,6 +103,7 @@ 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
@@ -112,20 +114,25 @@ jobs:
112
114
sudo chmod 777 /mnt/images
113
115
openstack image unset --property signature_verified "${{ steps.manifest.outputs.image-id }}"
114
116
openstack image save --file /mnt/images/${{ steps.manifest.outputs.image-name }}.qcow2 ${{ steps.manifest.outputs.image-id }}
117
+ if : github.event_name == 'schedule'
115
118
116
119
- name : Set up QEMU
117
120
uses : docker/setup-qemu-action@v3
121
+ if : github.event_name == 'schedule'
118
122
119
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
129
- name : mkdir for mount
125
130
run : sudo mkdir -p './${{ steps.manifest.outputs.image-name }}'
131
+ if : github.event_name == 'schedule'
126
132
127
133
- name : mount qcow2 file
128
134
run : sudo guestmount -a /mnt/images/${{ steps.manifest.outputs.image-name }}.qcow2 -i --ro -o allow_other './${{ steps.manifest.outputs.image-name }}'
135
+ if : github.event_name == 'schedule'
129
136
130
137
- name : Run Trivy vulnerability scanner
131
138
uses :
aquasecurity/[email protected]
@@ -138,12 +145,14 @@ jobs:
138
145
# turn off secret scanning to speed things up
139
146
env :
140
147
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
148
+ if : github.event_name == 'schedule'
141
149
142
150
- name : Upload Trivy scan results to GitHub Security tab
143
151
uses : github/codeql-action/upload-sarif@v3
144
152
with :
145
153
sarif_file : " ${{ steps.manifest.outputs.image-name }}.sarif"
146
- category : " ${{ matrix.os_version }}-${{ matrix.build }}"
154
+ category : " ${{ matrix.build.label }}"
155
+ if : github.event_name == 'schedule'
147
156
148
157
- name : Fail if scan has CRITICAL vulnerabilities
149
158
uses :
aquasecurity/[email protected]
@@ -157,16 +166,18 @@ jobs:
157
166
ignore-unfixed : true
158
167
env :
159
168
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
169
+ if : github.event_name == 'schedule'
160
170
161
171
- 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
172
+ if : github.event_name == 'schedule' && failure() && steps.packer_build.outcome == 'success' # Runs if the Trivy scan found crit vulnerabilities or failed
163
173
run : |
164
174
. venv/bin/activate
165
175
echo "Deleting new image due to critical vulnerabilities or scan failure ..."
166
176
openstack image delete "${{ steps.manifest.outputs.image-id }}"
177
+ if : github.event_name == 'schedule'
167
178
168
- - name : Delete old latest image
169
- if : success() # Runs only if Trivy scan passed
179
+ - name : Delete old image
180
+ if : github.event_name == 'schedule'
170
181
run : |
171
182
. venv/bin/activate
172
183
IMAGE_COUNT=$(openstack image list --name ${{ steps.manifest.outputs.image-name }} -f value -c ID | wc -l)
@@ -181,8 +192,9 @@ jobs:
181
192
upload :
182
193
name : upload-nightly-targets
183
194
needs : openstack
195
+ if : github.event_name == 'schedule'
184
196
concurrency :
185
- group : ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os_version }}-${{ matrix.image }}-${{ matrix.target_cloud }}
197
+ group : ${{ github.workflow }}-${{ github.ref }}-${{ matrix.builds.label }}-${{ matrix.target_cloud }}
186
198
cancel-in-progress : true
187
199
runs-on : ubuntu-22.04
188
200
strategy :
@@ -192,21 +204,16 @@ jobs:
192
204
- LEAFCLOUD
193
205
- SMS
194
206
- ARCUS
195
- os_version :
196
- - RL8
197
- - RL9
198
- image :
199
- - rocky-latest
200
- - rocky-latest-cuda
207
+ builds :
208
+ - image : RL8-ofed-latest
209
+ - image : RL9-ofed-latest
210
+ - image : RL9-cuda-latest
201
211
exclude :
202
- - os_version : RL8
203
- image : rocky-latest-cuda
204
- - target_cloud : LEAFCLOUD
212
+ - target_cloud : LEAFCLOUD # why?? Should this not be source_cloud/vars.CI_CLOUD
205
213
env :
206
214
OS_CLOUD : openstack
207
215
SOURCE_CLOUD : ${{ github.event.inputs.ci_cloud || vars.CI_CLOUD }}
208
216
TARGET_CLOUD : ${{ matrix.target_cloud }}
209
- IMAGE_NAME : " ${{ matrix.image }}-${{ matrix.os_version }}"
210
217
steps :
211
218
- uses : actions/checkout@v2
212
219
@@ -234,16 +241,16 @@ jobs:
234
241
run : |
235
242
. venv/bin/activate
236
243
export OS_CLIENT_CONFIG_FILE=~/.config/openstack/source_clouds.yaml
237
- openstack image save --file ${{ env.IMAGE_NAME }} ${{ env.IMAGE_NAME }}
244
+ openstack image save --file ${{ build.image }} ${{ build.image }}
238
245
shell : bash
239
246
240
247
- name : Upload to target cloud
241
248
run : |
242
249
. venv/bin/activate
243
250
export OS_CLIENT_CONFIG_FILE=~/.config/openstack/target_clouds.yaml
244
251
245
- openstack image create "${{ env.IMAGE_NAME }}" \
246
- --file "${{ env.IMAGE_NAME }}" \
252
+ openstack image create "${{ build.image }}" \
253
+ --file "${{ build.image }}" \
247
254
--disk-format qcow2 \
248
255
shell : bash
249
256
@@ -252,9 +259,9 @@ jobs:
252
259
. venv/bin/activate
253
260
export OS_CLIENT_CONFIG_FILE=~/.config/openstack/target_clouds.yaml
254
261
255
- IMAGE_COUNT=$(openstack image list --name ${{ env.IMAGE_NAME }} -f value -c ID | wc -l)
262
+ IMAGE_COUNT=$(openstack image list --name ${{ build.image }} -f value -c ID | wc -l)
256
263
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)
264
+ OLD_IMAGE_ID=$(openstack image list --sort created_at:asc --name "${{ build.image }}" -f value -c ID | head -n 1)
258
265
openstack image delete "$OLD_IMAGE_ID"
259
266
else
260
267
echo "Only one image exists, skipping deletion."
0 commit comments