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.
13name : Build nightly image
24on :
35 workflow_dispatch :
1416 - cron : ' 0 0 * * *' # Run at midnight
1517
1618jobs :
17- openstack :
18- name : openstack -imagebuild
19+ build :
20+ name : nightly -imagebuild
1921 concurrency :
2022 group : ${{ github.workflow }}-${{ github.ref }}-${{ matrix.builds.label }}
2123 cancel-in-progress : true
3739 ANSIBLE_FORCE_COLOR : True
3840 OS_CLOUD : openstack
3941 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 }}
4243
4344 steps :
4445 - uses : actions/checkout@v2
8788 -var-file=$PKR_VAR_environment_root/${{ env.CI_CLOUD }}.pkrvars.hcl \
8889 -var source_image_name=${{ matrix.builds.source_image_name }} \
8990 -var image_name=${{ matrix.builds.label }} \
90- -var image_version=${{ env.IMAGE_SUFFIX }} \
91+ -var image_version=${{ env.IMAGE_VERSION }} \
9192 -var inventory_groups=${{ matrix.builds.inventory_groups }} \
9293 openstack.pkr.hcl
9394 env :
@@ -102,6 +103,7 @@ jobs:
102103 sleep 5
103104 done
104105 IMAGE_NAME=$(openstack image show -f value -c name $IMAGE_ID)
106+ echo image: ${IMAGE_NAME} ${IMAGE_ID}
105107 echo "image-name=${IMAGE_NAME}" >> "$GITHUB_OUTPUT"
106108 echo "image-id=$IMAGE_ID" >> "$GITHUB_OUTPUT"
107109
@@ -112,20 +114,25 @@ jobs:
112114 sudo chmod 777 /mnt/images
113115 openstack image unset --property signature_verified "${{ steps.manifest.outputs.image-id }}"
114116 openstack image save --file /mnt/images/${{ steps.manifest.outputs.image-name }}.qcow2 ${{ steps.manifest.outputs.image-id }}
117+ if : github.event_name == 'schedule'
115118
116119 - name : Set up QEMU
117120 uses : docker/setup-qemu-action@v3
121+ if : github.event_name == 'schedule'
118122
119123 - name : install libguestfs
120124 run : |
121125 sudo apt -y update
122126 sudo apt -y install libguestfs-tools
127+ if : github.event_name == 'schedule'
123128
124129 - name : mkdir for mount
125130 run : sudo mkdir -p './${{ steps.manifest.outputs.image-name }}'
131+ if : github.event_name == 'schedule'
126132
127133 - name : mount qcow2 file
128134 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'
129136
130137 - name : Run Trivy vulnerability scanner
131138 uses :
aquasecurity/[email protected] @@ -138,12 +145,14 @@ jobs:
138145 # turn off secret scanning to speed things up
139146 env :
140147 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
148+ if : github.event_name == 'schedule'
141149
142150 - name : Upload Trivy scan results to GitHub Security tab
143151 uses : github/codeql-action/upload-sarif@v3
144152 with :
145153 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'
147156
148157 - name : Fail if scan has CRITICAL vulnerabilities
149158 uses :
aquasecurity/[email protected] @@ -157,16 +166,18 @@ jobs:
157166 ignore-unfixed : true
158167 env :
159168 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
169+ if : github.event_name == 'schedule'
160170
161171 - 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
163173 run : |
164174 . venv/bin/activate
165175 echo "Deleting new image due to critical vulnerabilities or scan failure ..."
166176 openstack image delete "${{ steps.manifest.outputs.image-id }}"
177+ if : github.event_name == 'schedule'
167178
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'
170181 run : |
171182 . venv/bin/activate
172183 IMAGE_COUNT=$(openstack image list --name ${{ steps.manifest.outputs.image-name }} -f value -c ID | wc -l)
@@ -181,8 +192,9 @@ jobs:
181192 upload :
182193 name : upload-nightly-targets
183194 needs : openstack
195+ if : github.event_name == 'schedule'
184196 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 }}
186198 cancel-in-progress : true
187199 runs-on : ubuntu-22.04
188200 strategy :
@@ -192,21 +204,16 @@ jobs:
192204 - LEAFCLOUD
193205 - SMS
194206 - 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
201211 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
205213 env :
206214 OS_CLOUD : openstack
207215 SOURCE_CLOUD : ${{ github.event.inputs.ci_cloud || vars.CI_CLOUD }}
208216 TARGET_CLOUD : ${{ matrix.target_cloud }}
209- IMAGE_NAME : " ${{ matrix.image }}-${{ matrix.os_version }}"
210217 steps :
211218 - uses : actions/checkout@v2
212219
@@ -234,16 +241,16 @@ jobs:
234241 run : |
235242 . venv/bin/activate
236243 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 }}
238245 shell : bash
239246
240247 - name : Upload to target cloud
241248 run : |
242249 . venv/bin/activate
243250 export OS_CLIENT_CONFIG_FILE=~/.config/openstack/target_clouds.yaml
244251
245- openstack image create "${{ env.IMAGE_NAME }}" \
246- --file "${{ env.IMAGE_NAME }}" \
252+ openstack image create "${{ build.image }}" \
253+ --file "${{ build.image }}" \
247254 --disk-format qcow2 \
248255 shell : bash
249256
@@ -252,9 +259,9 @@ jobs:
252259 . venv/bin/activate
253260 export OS_CLIENT_CONFIG_FILE=~/.config/openstack/target_clouds.yaml
254261
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)
256263 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)
258265 openstack image delete "$OLD_IMAGE_ID"
259266 else
260267 echo "Only one image exists, skipping deletion."
0 commit comments