Skip to content

Commit c28abb2

Browse files
authored
[summarize-checks] Add link to run that set status (#36434)
1 parent 6242f99 commit c28abb2

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

.github/workflows/src/summarize-checks/summarize-checks.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ import path from "path";
130130
* @property {string} name
131131
* @property {string} summary
132132
* @property {"pending" | keyof typeof CheckConclusion} result
133+
* @property {string} [target_url]
133134
*/
134135

135136
// Placing these configuration items here until we decide another way to pull them in.
@@ -298,6 +299,9 @@ export default async function summarizeChecks({ github, context, core }) {
298299
const targetBranch = context.payload.pull_request?.base?.ref;
299300
core.info(`PR target branch: ${targetBranch}`);
300301

302+
// Default target is this run itself
303+
const target_url = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
304+
301305
await summarizeChecksImpl(
302306
github,
303307
core,
@@ -307,6 +311,7 @@ export default async function summarizeChecks({ github, context, core }) {
307311
head_sha,
308312
context.eventName,
309313
targetBranch,
314+
target_url,
310315
);
311316
}
312317

@@ -341,6 +346,7 @@ export function outputRunDetails(core, requiredCheckRuns, fyiCheckRuns) {
341346
* @param {string} head_sha
342347
* @param {string} event_name
343348
* @param {string} targetBranch
349+
* @param {string} target_url
344350
* @returns {Promise<void>}
345351
*/
346352
export async function summarizeChecksImpl(
@@ -352,6 +358,7 @@ export async function summarizeChecksImpl(
352358
head_sha,
353359
event_name,
354360
targetBranch,
361+
target_url,
355362
) {
356363
core.info(`Handling ${event_name} event for PR #${issue_number} in ${owner}/${repo}.`);
357364

@@ -428,6 +435,8 @@ export async function summarizeChecksImpl(
428435
impactAssessment !== undefined,
429436
);
430437

438+
automatedChecksMet.target_url = target_url;
439+
431440
core.info(
432441
`Updating comment '${NEXT_STEPS_COMMENT_ID}' on ${owner}/${repo}#${issue_number} with body: ${commentBody}`,
433442
);
@@ -482,7 +491,7 @@ export async function updateCommitStatus(github, core, owner, repo, head_sha, ch
482491
? checkResult.summary.substring(0, 137) + "..."
483492
: checkResult.summary,
484493
context: checkResult.name,
485-
// target_url: undefined, // Optional: add a URL if you want to link to more details
494+
target_url: checkResult.target_url,
486495
});
487496

488497
core.info(

0 commit comments

Comments
 (0)