File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -155,6 +155,42 @@ runs:
155155 version : v0.69.3
156156 cache : true
157157
158+ - name : Ensure Trivy JUnit template
159+ shell : bash
160+ run : |
161+ set -euo pipefail
162+
163+ TEMPLATE_PATH="$HOME/.local/bin/trivy-bin/contrib/junit.tpl"
164+
165+ # If the template already exists, nothing to do
166+ if [ -f "$TEMPLATE_PATH" ]; then
167+ echo "Trivy JUnit template already present at $TEMPLATE_PATH"
168+ exit 0
169+ fi
170+
171+ mkdir -p "$(dirname "$TEMPLATE_PATH")"
172+
173+ # Determine installed Trivy version
174+ TRIVY_VERSION_RAW="$(trivy --version | awk '/Version:/ {print $2}' || true)"
175+ if [ -z "$TRIVY_VERSION_RAW" ]; then
176+ echo "::error::Could not determine Trivy version from 'trivy --version'"
177+ trivy --version || true
178+ exit 1
179+ fi
180+
181+ # Normalize to tag format (ensure leading "v")
182+ TRIVY_TAG="v${TRIVY_VERSION_RAW#v}"
183+
184+ TEMPLATE_URL="https://raw.githubusercontent.com/aquasecurity/trivy/${TRIVY_TAG}/contrib/junit.tpl"
185+ echo "Downloading Trivy JUnit template from ${TEMPLATE_URL}"
186+
187+ if ! curl -fsSL "$TEMPLATE_URL" -o "$TEMPLATE_PATH"; then
188+ echo "::error::Failed to download Trivy JUnit template from ${TEMPLATE_URL}"
189+ exit 1
190+ fi
191+
192+ echo "Trivy JUnit template downloaded to $TEMPLATE_PATH"
193+
158194 - name : Restore trivy cache
159195 id : cache-trivy-restore
160196 uses : actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
You can’t perform that action at this time.
0 commit comments