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:
committed by
pullfrog[bot]
parent
bfe72ac2cf
commit
adc165d95f
@@ -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>`;
|
||||
function buildPullfrogFooter(params) {
|
||||
const parts = [];
|
||||
if (params.triggeredBy) {
|
||||
parts.push("Triggered by [Pullfrog](https://pullfrog.com)");
|
||||
if (params.customParts) {
|
||||
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) {
|
||||
parts.push(`Using [${params.agent.displayName}](${params.agent.url})`);
|
||||
}
|
||||
if (params.customParts) {
|
||||
parts.push(...params.customParts);
|
||||
}
|
||||
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.triggeredBy) {
|
||||
parts.push("Triggered by [Pullfrog](https://pullfrog.com)");
|
||||
}
|
||||
const allParts = [
|
||||
...parts,
|
||||
@@ -140721,7 +140723,7 @@ async function buildCommentFooter({
|
||||
}) {
|
||||
const repoContext = parseRepoContext();
|
||||
const runId = process.env.GITHUB_RUN_ID;
|
||||
let workflowRunHtmlUrl;
|
||||
let jobId;
|
||||
if (runId && octokit) {
|
||||
try {
|
||||
const { data: jobs } = await octokit.rest.actions.listJobsForWorkflowRun({
|
||||
@@ -140729,7 +140731,7 @@ async function buildCommentFooter({
|
||||
repo: repoContext.name,
|
||||
run_id: parseInt(runId, 10)
|
||||
});
|
||||
workflowRunHtmlUrl = jobs.jobs[0]?.html_url ?? void 0;
|
||||
jobId = jobs.jobs[0]?.id.toString();
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
@@ -140739,12 +140741,7 @@ async function buildCommentFooter({
|
||||
displayName: agent2?.displayName || "Unknown agent",
|
||||
url: agent2?.url || "https://pullfrog.com"
|
||||
},
|
||||
workflowRun: runId ? {
|
||||
owner: repoContext.owner,
|
||||
repo: repoContext.name,
|
||||
runId,
|
||||
...workflowRunHtmlUrl ? { htmlUrl: workflowRunHtmlUrl } : {}
|
||||
} : void 0
|
||||
workflowRun: runId ? { owner: repoContext.owner, repo: repoContext.name, runId, jobId } : void 0
|
||||
};
|
||||
if (customParts && customParts.length > 0) {
|
||||
return buildPullfrogFooter({ ...footerParams, customParts });
|
||||
|
||||
+5
-10
@@ -26,7 +26,7 @@ async function buildCommentFooter({
|
||||
const repoContext = parseRepoContext();
|
||||
const runId = process.env.GITHUB_RUN_ID;
|
||||
|
||||
let workflowRunHtmlUrl: string | undefined;
|
||||
let jobId: string | undefined;
|
||||
if (runId && octokit) {
|
||||
try {
|
||||
// fetch jobs to get the job URL for deep linking
|
||||
@@ -35,10 +35,10 @@ async function buildCommentFooter({
|
||||
repo: repoContext.name,
|
||||
run_id: parseInt(runId, 10),
|
||||
});
|
||||
// use the first job's URL if available
|
||||
workflowRunHtmlUrl = jobs.jobs[0]?.html_url ?? undefined;
|
||||
// use the first job's ID available
|
||||
jobId = jobs.jobs[0]?.id.toString();
|
||||
} 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",
|
||||
},
|
||||
workflowRun: runId
|
||||
? {
|
||||
owner: repoContext.owner,
|
||||
repo: repoContext.name,
|
||||
runId,
|
||||
...(workflowRunHtmlUrl ? { htmlUrl: workflowRunHtmlUrl } : {}),
|
||||
}
|
||||
? { owner: repoContext.owner, repo: repoContext.name, runId, jobId }
|
||||
: undefined,
|
||||
};
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@ export interface BuildPullfrogFooterParams {
|
||||
agent?: AgentInfo | undefined;
|
||||
/** add "View workflow run" link */
|
||||
workflowRun?: WorkflowRunFooterInfo | undefined;
|
||||
/** alternative: just pass a pre-built URL directly (for shortlinks etc.) */
|
||||
workflowRunUrl?: string | undefined;
|
||||
/** arbitrary custom parts (e.g., action links) */
|
||||
customParts?: string[];
|
||||
}
|
||||
@@ -29,26 +31,29 @@ export interface BuildPullfrogFooterParams {
|
||||
/**
|
||||
* build a pullfrog footer with configurable parts
|
||||
* 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 {
|
||||
const parts: string[] = [];
|
||||
|
||||
if (params.triggeredBy) {
|
||||
parts.push("Triggered by [Pullfrog](https://pullfrog.com)");
|
||||
if (params.customParts) {
|
||||
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) {
|
||||
parts.push(`Using [${params.agent.displayName}](${params.agent.url})`);
|
||||
}
|
||||
|
||||
if (params.customParts) {
|
||||
parts.push(...params.customParts);
|
||||
}
|
||||
|
||||
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.triggeredBy) {
|
||||
parts.push("Triggered by [Pullfrog](https://pullfrog.com)");
|
||||
}
|
||||
|
||||
const allParts = [
|
||||
|
||||
Reference in New Issue
Block a user