Tweak comment footer (#208)

* Tweak comment footer

* take 2

* tweak

* tweak

* add dev path

* defensively guard against missing job in the array
This commit is contained in:
Mateusz Burzyński
2026-02-03 18:49:48 +00:00
committed by pullfrog[bot]
parent bfe72ac2cf
commit adc165d95f
3 changed files with 34 additions and 37 deletions
+14 -17
View File
@@ -136836,19 +136836,21 @@ var PULLFROG_DIVIDER = "<!-- PULLFROG_DIVIDER_DO_NOT_REMOVE_PLZ -->";
var FROG_LOGO = `<a href="https://pullfrog.com"><picture><source media="(prefers-color-scheme: dark)" srcset="https://pullfrog.com/logos/frog-white-full-18px.png"><img src="https://pullfrog.com/logos/frog-green-full-18px.png" width="9px" height="9px" style="vertical-align: middle; " alt="Pullfrog"></picture></a>`; var FROG_LOGO = `<a href="https://pullfrog.com"><picture><source media="(prefers-color-scheme: dark)" srcset="https://pullfrog.com/logos/frog-white-full-18px.png"><img src="https://pullfrog.com/logos/frog-green-full-18px.png" width="9px" height="9px" style="vertical-align: middle; " alt="Pullfrog"></picture></a>`;
function buildPullfrogFooter(params) { function buildPullfrogFooter(params) {
const parts = []; const parts = [];
if (params.triggeredBy) { if (params.customParts) {
parts.push("Triggered by [Pullfrog](https://pullfrog.com)"); parts.push(...params.customParts);
}
if (params.workflowRunUrl) {
parts.push(`[View workflow run](${params.workflowRunUrl})`);
} else if (params.workflowRun) {
const baseUrl = `https://github.com/${params.workflowRun.owner}/${params.workflowRun.repo}/actions/runs/${params.workflowRun.runId}`;
const url4 = params.workflowRun.jobId ? `${baseUrl}/job/${params.workflowRun.jobId}` : baseUrl;
parts.push(`[View workflow run](${url4})`);
} }
if (params.agent) { if (params.agent) {
parts.push(`Using [${params.agent.displayName}](${params.agent.url})`); parts.push(`Using [${params.agent.displayName}](${params.agent.url})`);
} }
if (params.customParts) { if (params.triggeredBy) {
parts.push(...params.customParts); parts.push("Triggered by [Pullfrog](https://pullfrog.com)");
}
if (params.workflowRun) {
const baseUrl = `https://github.com/${params.workflowRun.owner}/${params.workflowRun.repo}/actions/runs/${params.workflowRun.runId}`;
const url4 = params.workflowRun.jobId ? `${baseUrl}/job/${params.workflowRun.jobId}` : baseUrl;
parts.push(`[View workflow run](${url4})`);
} }
const allParts = [ const allParts = [
...parts, ...parts,
@@ -140721,7 +140723,7 @@ async function buildCommentFooter({
}) { }) {
const repoContext = parseRepoContext(); const repoContext = parseRepoContext();
const runId = process.env.GITHUB_RUN_ID; const runId = process.env.GITHUB_RUN_ID;
let workflowRunHtmlUrl; let jobId;
if (runId && octokit) { if (runId && octokit) {
try { try {
const { data: jobs } = await octokit.rest.actions.listJobsForWorkflowRun({ const { data: jobs } = await octokit.rest.actions.listJobsForWorkflowRun({
@@ -140729,7 +140731,7 @@ async function buildCommentFooter({
repo: repoContext.name, repo: repoContext.name,
run_id: parseInt(runId, 10) run_id: parseInt(runId, 10)
}); });
workflowRunHtmlUrl = jobs.jobs[0]?.html_url ?? void 0; jobId = jobs.jobs[0]?.id.toString();
} catch { } catch {
} }
} }
@@ -140739,12 +140741,7 @@ async function buildCommentFooter({
displayName: agent2?.displayName || "Unknown agent", displayName: agent2?.displayName || "Unknown agent",
url: agent2?.url || "https://pullfrog.com" url: agent2?.url || "https://pullfrog.com"
}, },
workflowRun: runId ? { workflowRun: runId ? { owner: repoContext.owner, repo: repoContext.name, runId, jobId } : void 0
owner: repoContext.owner,
repo: repoContext.name,
runId,
...workflowRunHtmlUrl ? { htmlUrl: workflowRunHtmlUrl } : {}
} : void 0
}; };
if (customParts && customParts.length > 0) { if (customParts && customParts.length > 0) {
return buildPullfrogFooter({ ...footerParams, customParts }); return buildPullfrogFooter({ ...footerParams, customParts });
+5 -10
View File
@@ -26,7 +26,7 @@ async function buildCommentFooter({
const repoContext = parseRepoContext(); const repoContext = parseRepoContext();
const runId = process.env.GITHUB_RUN_ID; const runId = process.env.GITHUB_RUN_ID;
let workflowRunHtmlUrl: string | undefined; let jobId: string | undefined;
if (runId && octokit) { if (runId && octokit) {
try { try {
// fetch jobs to get the job URL for deep linking // fetch jobs to get the job URL for deep linking
@@ -35,10 +35,10 @@ async function buildCommentFooter({
repo: repoContext.name, repo: repoContext.name,
run_id: parseInt(runId, 10), run_id: parseInt(runId, 10),
}); });
// use the first job's URL if available // use the first job's ID available
workflowRunHtmlUrl = jobs.jobs[0]?.html_url ?? undefined; jobId = jobs.jobs[0]?.id.toString();
} catch { } catch {
// fall back to building URL from runId if jobs can't be fetched // fall back to computed URL from runId alone
} }
} }
@@ -49,12 +49,7 @@ async function buildCommentFooter({
url: agent?.url || "https://pullfrog.com", url: agent?.url || "https://pullfrog.com",
}, },
workflowRun: runId workflowRun: runId
? { ? { owner: repoContext.owner, repo: repoContext.name, runId, jobId }
owner: repoContext.owner,
repo: repoContext.name,
runId,
...(workflowRunHtmlUrl ? { htmlUrl: workflowRunHtmlUrl } : {}),
}
: undefined, : undefined,
}; };
+15 -10
View File
@@ -22,6 +22,8 @@ export interface BuildPullfrogFooterParams {
agent?: AgentInfo | undefined; agent?: AgentInfo | undefined;
/** add "View workflow run" link */ /** add "View workflow run" link */
workflowRun?: WorkflowRunFooterInfo | undefined; workflowRun?: WorkflowRunFooterInfo | undefined;
/** alternative: just pass a pre-built URL directly (for shortlinks etc.) */
workflowRunUrl?: string | undefined;
/** arbitrary custom parts (e.g., action links) */ /** arbitrary custom parts (e.g., action links) */
customParts?: string[]; customParts?: string[];
} }
@@ -29,26 +31,29 @@ export interface BuildPullfrogFooterParams {
/** /**
* build a pullfrog footer with configurable parts * build a pullfrog footer with configurable parts
* always includes: frog logo at start, pullfrog.com link and X link at end * always includes: frog logo at start, pullfrog.com link and X link at end
* order: action links (customParts) > workflow run > agent > attribution > reference links
*/ */
export function buildPullfrogFooter(params: BuildPullfrogFooterParams): string { export function buildPullfrogFooter(params: BuildPullfrogFooterParams): string {
const parts: string[] = []; const parts: string[] = [];
if (params.triggeredBy) { if (params.customParts) {
parts.push("Triggered by [Pullfrog](https://pullfrog.com)"); parts.push(...params.customParts);
}
if (params.workflowRunUrl) {
parts.push(`[View workflow run](${params.workflowRunUrl})`);
} else if (params.workflowRun) {
const baseUrl = `https://github.com/${params.workflowRun.owner}/${params.workflowRun.repo}/actions/runs/${params.workflowRun.runId}`;
const url = params.workflowRun.jobId ? `${baseUrl}/job/${params.workflowRun.jobId}` : baseUrl;
parts.push(`[View workflow run](${url})`);
} }
if (params.agent) { if (params.agent) {
parts.push(`Using [${params.agent.displayName}](${params.agent.url})`); parts.push(`Using [${params.agent.displayName}](${params.agent.url})`);
} }
if (params.customParts) { if (params.triggeredBy) {
parts.push(...params.customParts); parts.push("Triggered by [Pullfrog](https://pullfrog.com)");
}
if (params.workflowRun) {
const baseUrl = `https://github.com/${params.workflowRun.owner}/${params.workflowRun.repo}/actions/runs/${params.workflowRun.runId}`;
const url = params.workflowRun.jobId ? `${baseUrl}/job/${params.workflowRun.jobId}` : baseUrl;
parts.push(`[View workflow run](${url})`);
} }
const allParts = [ const allParts = [