File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -162,6 +162,8 @@ jobs:
162162
163163 security-scan :
164164 name : Security scan
165+ outputs :
166+ sarif_files : ${{ steps.get_sarif_files.outputs.sarif-files }}
165167 runs-on : ubuntu-latest
166168 needs : build
167169 timeout-minutes : 30
@@ -192,7 +194,30 @@ jobs:
192194 cp build/microk8s.snap .
193195 unsquashfs microk8s.snap
194196 trivy rootfs ./squashfs-root/ --format sarif > sarifs/snap.sarif
195- - name : Upload Trivy scan results to GitHub Security tab
197+ - name : Generate list of SARIF files
198+ id : get_sarif_files
199+ run : |
200+ sarif_files=$(find sarifs -name "*.sarif" -printf "%P\n" | jq -R -s -c 'split("\n") | map(select(length > 0))')
201+ echo "sarif-files=$sarif_files" >> "$GITHUB_OUTPUT"
202+
203+ upload_sarifs_matrix :
204+ needs : security-scan
205+ runs-on : ubuntu-latest
206+ strategy :
207+ fail-fast : true
208+ matrix :
209+ sarif_file_path : ${{ fromJson(needs.security-scan.outputs.sarif_files) }}
210+ steps :
211+ - name : Checkout repository
212+ uses : actions/checkout@v4
213+ - name : Prepare SARIF category
214+ id : prepare_category
215+ run : |
216+ sarif_file="${{ matrix.sarif_file_path }}"
217+ base_name=$(basename "$sarif_file" .sarif)
218+ echo "category=$base_name" >> "$GITHUB_OUTPUT"
219+ - name : Upload SARIF file: ${{ matrix.sarif_file_path }}
196220 uses : github/codeql-action/upload-sarif@v3
197221 with :
198- sarif_file : " sarifs"
222+ sarif_file : ${{ matrix.sarif_file_path }}
223+ category : ${{ steps.prepare_category.outputs.category }}
You can’t perform that action at this time.
0 commit comments