1
- # NB: When run via workflow_dispatch, image scanning and distribution to other clouds does not happen
1
+ # NB: When run in a non-main branch ( via workflow_dispatch) , image scanning and distribution to other clouds does not happen
2
2
# on the basis that in this case a fatimage must be built and will be scanned.
3
3
name : Build nightly image
4
4
on :
@@ -108,7 +108,7 @@ jobs:
108
108
echo "image-id=$IMAGE_ID" >> "$GITHUB_OUTPUT"
109
109
110
110
- name : Download image
111
- if : github.event_name == 'schedule '
111
+ if : githib.ref_name == 'main '
112
112
run : |
113
113
. venv/bin/activate
114
114
sudo mkdir /mnt/images
@@ -117,23 +117,23 @@ jobs:
117
117
openstack image save --file /mnt/images/${{ steps.manifest.outputs.image-name }}.qcow2 ${{ steps.manifest.outputs.image-id }}
118
118
119
119
- name : Set up QEMU
120
- if : github.event_name == 'schedule '
120
+ if : githib.ref_name == 'main '
121
121
uses : docker/setup-qemu-action@v3
122
122
123
123
- name : Install libguestfs
124
124
run : |
125
125
sudo apt -y update
126
126
sudo apt -y install libguestfs-tools
127
- if : github.event_name == 'schedule '
127
+ if : githib.ref_name == 'main '
128
128
129
129
- name : Mount image
130
- if : github.event_name == 'schedule '
130
+ if : githib.ref_name == 'main '
131
131
run : |
132
132
sudo mkdir -p './${{ steps.manifest.outputs.image-name }}'
133
133
sudo guestmount -a /mnt/images/${{ steps.manifest.outputs.image-name }}.qcow2 -i --ro -o allow_other './${{ steps.manifest.outputs.image-name }}'
134
134
135
135
- name : Run Trivy vulnerability scanner
136
- if : github.event_name == 'schedule '
136
+ if : githib.ref_name == 'main '
137
137
uses :
aquasecurity/[email protected]
138
138
with :
139
139
scan-type : fs
@@ -146,14 +146,14 @@ jobs:
146
146
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
147
147
148
148
- name : Upload Trivy scan results to GitHub Security tab
149
- if : github.event_name == 'schedule '
149
+ if : githib.ref_name == 'main '
150
150
uses : github/codeql-action/upload-sarif@v3
151
151
with :
152
152
sarif_file : " ${{ steps.manifest.outputs.image-name }}.sarif"
153
153
category : " ${{ matrix.build.label }}"
154
154
155
155
- name : Fail if scan has CRITICAL vulnerabilities
156
- if : github.event_name == 'schedule '
156
+ if : githib.ref_name == 'main '
157
157
uses :
aquasecurity/[email protected]
158
158
with :
159
159
scan-type : fs
@@ -168,14 +168,14 @@ jobs:
168
168
169
169
170
170
- name : Delete new image if Trivy scan fails
171
- if : github.event_name == 'schedule ' && failure() && steps.packer_build.outcome == 'success' # Runs if the Trivy scan found crit vulnerabilities or failed
171
+ if : githib.ref_name == 'main ' && failure() && steps.packer_build.outcome == 'success' # Runs if the Trivy scan found crit vulnerabilities or failed
172
172
run : |
173
173
. venv/bin/activate
174
174
echo "Deleting new image due to critical vulnerabilities or scan failure ..."
175
175
openstack image delete "${{ steps.manifest.outputs.image-id }}"
176
176
177
177
- name : Delete old image
178
- if : github.event_name == 'schedule '
178
+ if : githib.ref_name == 'main '
179
179
run : |
180
180
. venv/bin/activate
181
181
IMAGE_COUNT=$(openstack image list --name ${{ steps.manifest.outputs.image-name }} -f value -c ID | wc -l)
@@ -190,7 +190,7 @@ jobs:
190
190
upload :
191
191
name : upload-nightly-targets
192
192
needs : build
193
- if : github.event_name == 'schedule '
193
+ if : githib.ref_name == 'main '
194
194
concurrency :
195
195
group : ${{ github.workflow }}-${{ github.ref }}-${{ matrix.builds.label }}-${{ matrix.target_cloud }}
196
196
cancel-in-progress : true
0 commit comments