From 6001bc9edcd2da8b2a5d51add0dc9560ab9b7400 Mon Sep 17 00:00:00 2001 From: Daz DeBoer Date: Sat, 4 Jun 2022 23:10:32 -0600 Subject: [PATCH] Improve build badgee for builds without scan links --- src/job-summary.ts | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/job-summary.ts b/src/job-summary.ts index c5dd440..5d82ba5 100644 --- a/src/job-summary.ts +++ b/src/job-summary.ts @@ -60,13 +60,10 @@ function writeSummaryTable(results: BuildResult[]): void { } function renderOutcome(result: BuildResult): string { - const badgeUrl = result.buildFailed - ? 'https://img.shields.io/badge/Build%20Scan%E2%84%A2-FAILED-red?logo=Gradle' - : 'https://img.shields.io/badge/Build%20Scan%E2%84%A2-SUCCESS-brightgreen?logo=Gradle' + const labelPart = result.buildScanUri ? 'Build%20Scan%E2%84%A2' : 'Build' + const outcomePart = result.buildFailed ? 'FAILED-red' : 'SUCCESS-brightgreen' + const badgeUrl = `https://img.shields.io/badge/${labelPart}-${outcomePart}?logo=Gradle` const badgeHtml = `Gradle Build` - - if (result.buildScanUri) { - return `${badgeHtml}` - } - return badgeHtml + const targetUrl = result.buildScanUri ? result.buildScanUri : '#' + return `${badgeHtml}` }