Skip to content

Commit 4848e4f

Browse files
committed
fix(ci): fix vulnerability check failure in dagger pipeline
Currently, the vulnerability check fails inside Dagger when bugs are found, preventing the report from being exported. This change adds error handling (|| true) to the govulncheck command to ensure the report is always generated. Vulnerability check ultimately results in a failure at github actions stage. Signed-off-by: Rayyan Khan <rayyanrehman101@gmail.com>
1 parent 3ecfe63 commit 4848e4f

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

.dagger/main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,9 +384,10 @@ func (m *HarborCli) VulnerabilityCheck(ctx context.Context) (string, error) {
384384
// Runs a vulnerability check using govulncheck and writes results to vulnerability-check.report
385385
func (m *HarborCli) VulnerabilityCheckReport(ctx context.Context) *dagger.File {
386386
report := "vulnerability-check.report"
387+
cmd := fmt.Sprintf("govulncheck ./... > %s || true", report)
387388
return m.vulnerabilityCheck(ctx).
388389
WithExec([]string{
389-
"sh", "-c", fmt.Sprintf("govulncheck ./... > %s", report),
390+
"sh", "-c", cmd,
390391
}).File(report)
391392
}
392393

@@ -397,6 +398,7 @@ func parsePlatform(platform string) (string, string, error) {
397398
return "", "", fmt.Errorf("invalid platform format: %s. Should be os/arch. E.g. darwin/amd64", platform)
398399
}
399400
return parts[0], parts[1], nil
401+
400402
}
401403

402404
func getVersion(tags []string) string {

.github/workflows/default.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ jobs:
9595
# Check if the lint report contains any content (error or issues)
9696
if ! grep -q "No vulnerabilities found." vulnerability-check.report; then
9797
# If the file contains content, output an error message and exit with code 1
98-
echo "⚠️ Linting issues found!" >> $GITHUB_STEP_SUMMARY
98+
echo "⚠️ Vulnerability issues found!" >> $GITHUB_STEP_SUMMARY
9999
exit 1
100100
fi
101101

0 commit comments

Comments
 (0)