Improve build badgee for builds without scan links

This commit is contained in:
Daz DeBoer 2022-06-04 23:10:32 -06:00
parent 5203a0b09d
commit 6001bc9edc
No known key found for this signature in database
GPG key ID: DD6B9F0B06683D5D

View file

@ -60,13 +60,10 @@ function writeSummaryTable(results: BuildResult[]): void {
} }
function renderOutcome(result: BuildResult): string { function renderOutcome(result: BuildResult): string {
const badgeUrl = result.buildFailed const labelPart = result.buildScanUri ? 'Build%20Scan%E2%84%A2' : 'Build'
? 'https://img.shields.io/badge/Build%20Scan%E2%84%A2-FAILED-red?logo=Gradle' const outcomePart = result.buildFailed ? 'FAILED-red' : 'SUCCESS-brightgreen'
: 'https://img.shields.io/badge/Build%20Scan%E2%84%A2-SUCCESS-brightgreen?logo=Gradle' const badgeUrl = `https://img.shields.io/badge/${labelPart}-${outcomePart}?logo=Gradle`
const badgeHtml = `<img src="${badgeUrl}" alt="Gradle Build">` const badgeHtml = `<img src="${badgeUrl}" alt="Gradle Build">`
const targetUrl = result.buildScanUri ? result.buildScanUri : '#'
if (result.buildScanUri) { return `<a href="${targetUrl}" rel="nofollow">${badgeHtml}</a>`
return `<a href="${result.buildScanUri}" rel="nofollow">${badgeHtml}</a>`
}
return badgeHtml
} }