@@ -100,24 +100,13 @@ jobs:
100
100
echo "image-name=${IMAGE_NAME}" >> "$GITHUB_OUTPUT"
101
101
echo "image-id=$IMAGE_ID" >> "$GITHUB_OUTPUT"
102
102
103
- - name : Delete old latest image
104
- run : |
105
- . venv/bin/activate
106
- IMAGE_COUNT=$(openstack image list --name ${{ steps.manifest.outputs.image-name }} -f value -c ID | wc -l)
107
- if [ "$IMAGE_COUNT" -gt 1 ]; then
108
- OLD_IMAGE_ID=$(openstack image list --sort created_at:asc --name "${{ steps.manifest.outputs.image-name }}" -f value -c ID | head -n 1)
109
- openstack image delete "$OLD_IMAGE_ID"
110
- else
111
- echo "Only one image exists, skipping deletion."
112
- fi
113
-
114
103
- name : Download image
115
104
run : |
116
105
. venv/bin/activate
117
106
sudo mkdir /mnt/images
118
107
sudo chmod 777 /mnt/images
119
- openstack image unset --property signature_verified "${{ steps.manifest.outputs.image-name }}"
120
- openstack image save --file /mnt/images/${{ steps.manifest.outputs.image-name }}.qcow2 ${{ steps.manifest.outputs.image-name }}
108
+ openstack image unset --property signature_verified "${{ steps.manifest.outputs.image-id }}"
109
+ openstack image save --file /mnt/images/${{ steps.manifest.outputs.image-name }}.qcow2 ${{ steps.manifest.outputs.image-id }}
121
110
122
111
- name : Set up QEMU
123
112
uses : docker/setup-qemu-action@v3
@@ -152,6 +141,7 @@ jobs:
152
141
category : " ${{ matrix.os_version }}-${{ matrix.build }}"
153
142
154
143
- name : Fail if scan has CRITICAL vulnerabilities
144
+ id : trivy_critical_check
155
145
uses :
aquasecurity/[email protected]
156
146
with :
157
147
scan-type : fs
@@ -161,6 +151,26 @@ jobs:
161
151
exit-code : ' 1'
162
152
severity : ' CRITICAL'
163
153
ignore-unfixed : true
154
+
155
+ - name : Delete new image if Trivy scan fails
156
+ if : steps.trivy_critical_check.outcome == 'failure' # Runs if the Trivy scan found CRITICAL vulnerabilities
157
+ run : |
158
+ . venv/bin/activate
159
+ echo "Deleting new image due to critical vulnerabilities..."
160
+ openstack image delete "${{ steps.manifest.outputs.image-id }}"
161
+
162
+ - name : Delete old latest image
163
+ if : steps.trivy_critical_check.outcome == 'success' # Runs only if Trivy scan passed
164
+ run : |
165
+ . venv/bin/activate
166
+ IMAGE_COUNT=$(openstack image list --name ${{ steps.manifest.outputs.image-name }} -f value -c ID | wc -l)
167
+ if [ "$IMAGE_COUNT" -gt 1 ]; then
168
+ OLD_IMAGE_ID=$(openstack image list --sort created_at:asc --name "${{ steps.manifest.outputs.image-name }}" -f value -c ID | head -n 1)
169
+ echo "Deleting old image ID: $OLD_IMAGE_ID"
170
+ openstack image delete "$OLD_IMAGE_ID"
171
+ else
172
+ echo "Only one image exists, skipping deletion."
173
+ fi
164
174
165
175
upload :
166
176
name : upload-nightly-targets
0 commit comments