@@ -6,14 +6,17 @@ const { getMessages } = require("./messages_core.cjs");
66const { sanitizeContent } = require ( "./sanitize_content.cjs" ) ;
77const { getPullRequestCreatedMessage, getIssueCreatedMessage, getCommitPushedMessage } = require ( "./messages_run_status.cjs" ) ;
88const { parseBoolTemplatable } = require ( "./templatable.cjs" ) ;
9+ const { generateXMLMarker } = require ( "./generate_footer.cjs" ) ;
910
1011/**
11- * Get the current workflow run ID from context or environment.
12+ * Build the workflow run URL from context and environment.
1213 * @param {any } context - GitHub Actions context
13- * @returns {string } The run ID, or empty string if not available
14+ * @returns {string } The workflow run URL
1415 */
15- function getRunId ( context ) {
16- return String ( context . runId || process . env . GITHUB_RUN_ID || "" ) ;
16+ function getRunUrl ( context ) {
17+ const runId = context . runId || process . env . GITHUB_RUN_ID || "" ;
18+ const githubServer = process . env . GITHUB_SERVER_URL || "https://github.com" ;
19+ return context . payload ?. repository ?. html_url ? `${ context . payload . repository . html_url } /actions/runs/${ runId } ` : `${ githubServer } /${ context . repo . owner } /${ context . repo . repo } /actions/runs/${ runId } ` ;
1720}
1821
1922/**
@@ -27,12 +30,10 @@ function getRunId(context) {
2730 */
2831async function updateActivationComment ( github , context , core , itemUrl , itemNumber , itemType = "pull_request" ) {
2932 const itemLabel = itemType === "issue" ? "issue" : "pull request" ;
30- const runId = getRunId ( context ) ;
33+ const workflowName = process . env . GH_AW_WORKFLOW_NAME || "Workflow" ;
34+ const runUrl = getRunUrl ( context ) ;
3135 const body = itemType === "issue" ? getIssueCreatedMessage ( { itemNumber, itemUrl } ) : getPullRequestCreatedMessage ( { itemNumber, itemUrl } ) ;
32- let linkMessage = `\n\n${ body } ` ;
33- if ( runId ) {
34- linkMessage += `\n\n<!-- gh-aw-run-id: ${ runId } -->` ;
35- }
36+ const linkMessage = `\n\n${ body } \n\n${ generateXMLMarker ( workflowName , runUrl ) } ` ;
3637 await updateActivationCommentWithMessage ( github , context , core , linkMessage , itemLabel , { targetIssueNumber : itemNumber } ) ;
3738}
3839
@@ -48,11 +49,9 @@ async function updateActivationComment(github, context, core, itemUrl, itemNumbe
4849 */
4950async function updateActivationCommentWithCommit ( github , context , core , commitSha , commitUrl , options = { } ) {
5051 const shortSha = commitSha . substring ( 0 , 7 ) ;
51- const runId = getRunId ( context ) ;
52- let message = `\n\n${ getCommitPushedMessage ( { commitSha, shortSha, commitUrl } ) } ` ;
53- if ( runId ) {
54- message += `\n\n<!-- gh-aw-run-id: ${ runId } -->` ;
55- }
52+ const workflowName = process . env . GH_AW_WORKFLOW_NAME || "Workflow" ;
53+ const runUrl = getRunUrl ( context ) ;
54+ const message = `\n\n${ getCommitPushedMessage ( { commitSha, shortSha, commitUrl } ) } \n\n${ generateXMLMarker ( workflowName , runUrl ) } ` ;
5655 await updateActivationCommentWithMessage ( github , context , core , message , "commit" , options ) ;
5756}
5857
0 commit comments