Skip to content

Commit

Permalink
Test job summary
Browse files Browse the repository at this point in the history
  • Loading branch information
isasmendiagus committed Jan 25, 2024
1 parent 9842d94 commit 5bc0ad7
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions src/services/report.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Licenses } from './result.service';
import * as core from '@actions/core';

export function getLicensesReport(licenses: Licenses[]): string {
let markdownTable = '| License | Copyleft | URL |\n';
Expand All @@ -11,3 +12,62 @@ export function getLicensesReport(licenses: Licenses[]): string {

return markdownTable;
}

const html = `
<!DOCTYPE html>
<html>
<head>
<style>
#donut-chart {
width: 200px;
height: 200px;
}
</style>
</head>
<body>
<div id="donut-chart"></div>
<script type="text/javascript">
function generateDonutChart(data) {
const svgns = "http://www.w3.org/2000/svg";
const chart = document.createElementNS(svgns, "svg");
chart.setAttribute("viewBox", "0 0 200 200");
let totalPercentage = 0;
for (const segment of data) {
const circle = document.createElementNS(svgns, "circle");
circle.setAttribute("r", "70");
circle.setAttribute("cx", "100");
circle.setAttribute("cy", "100");
circle.setAttribute("fill", "transparent");
circle.setAttribute("stroke", segment.color);
circle.setAttribute("stroke-width", "40");
// Calculating the stroke-dasharray
const circumference = 2 * Math.PI * 70;
const dashArray = circumference * segment.take / 100;
circle.setAttribute("stroke-dasharray", \`${dashArray} ${circumference - dashArray}\`);
circle.setAttribute("transform", \`rotate(${(totalPercentage / 100) * 360 - 90} 100 100)\`);
totalPercentage += segment.take;
chart.appendChild(circle);
}
document.getElementById("donut-chart").appendChild(chart);
}
generateDonutChart([
{color: "red", take: 20},
{color: "gray", take: 80}
]);
</script>
</body>
</html>
`;
export async function getJobSummary() {
await core.summary.addRaw(html).write();
}

0 comments on commit 5bc0ad7

Please sign in to comment.