From 78069b410aae95ad602912f1251a72854d48f248 Mon Sep 17 00:00:00 2001 From: David Losert Date: Sat, 17 Jun 2023 20:14:29 +0200 Subject: [PATCH] feat: Adds a link to the workflow run in the report (#235) --- src/index.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index 4652af7..4877f85 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,6 +2,7 @@ import { generateSummaryTableHtml } from './generateSummaryTableHtml.js'; import { parseVitestJsonFinal, parseVitestJsonSummary } from './parseJsonReports.js'; import { writeSummaryToPR } from './writeSummaryToPR.js'; import * as core from '@actions/core'; +import * as github from '@actions/github'; import { RequestError } from '@octokit/request-error' import { generateFileCoverageHtml } from './generateFileCoverageHtml.js'; import { getPullChanges } from './getPullChanges.js'; @@ -35,8 +36,11 @@ const run = async () => { summary.addDetails('File Coverage', fileTable) } + summary + .addRaw(`Generated in workflow #${github.context.runNumber}`) + try { - await writeSummaryToPR({ + await writeSummaryToPR({ summary, markerPostfix: getMarkerPostfix({ name, workingDirectory }) }); @@ -47,7 +51,7 @@ const run = async () => { Original Error was: [${error.name}] - ${error.message} ` ) - + } else { // Rethrow to handle it in the catch block of the run()-call. throw error; @@ -58,11 +62,17 @@ const run = async () => { }; function getMarkerPostfix({ name, workingDirectory }: { name: string, workingDirectory: string }) { - if(name) return name; - if(workingDirectory !== './') return workingDirectory; + if (name) return name; + if (workingDirectory !== './') return workingDirectory; return 'root' } +function getWorkflowSummaryURL() { + const { owner, repo } = github.context.repo; + const { runId } = github.context; + return `${github.context.serverUrl}/${owner}/${repo}/actions/runs/${runId}` +} + run().then(() => { core.info('Report generated successfully.');