@@ -191,8 +191,9 @@ class Utils {
191191 const exchangeUrl = jfrogCredentials . jfrogUrl . replace ( / \/ $ / , '' ) + '/access/api/v1/oidc/token' ;
192192 core . debug ( 'Exchanging GitHub JSON web token with a JFrog access token...' ) ;
193193 let projectKey = process . env . JF_PROJECT || '' ;
194- let jobId = process . env . GITHUB_JOB || '' ;
194+ let jobId = this . getGithubJobId ( ) ;
195195 let runId = process . env . GITHUB_RUN_ID || '' ;
196+ let githubRepository = process . env . GITHUB_REPOSITORY || '' ;
196197 const httpClient = new http_client_1 . HttpClient ( ) ;
197198 const data = `{
198199 "grant_type": "urn:ietf:params:oauth:grant-type:token-exchange",
@@ -202,6 +203,7 @@ class Utils {
202203 "project_key": "${ projectKey } ",
203204 "gh_job_id": "${ jobId } ",
204205 "gh_run_id": "${ runId } ",
206+ "gh_repo": "${ githubRepository } ",
205207 "application_key": "${ applicationKey } "
206208 }` ;
207209 const additionalHeaders = {
@@ -825,13 +827,16 @@ class Utils {
825827 }
826828 static getUsageBadge ( ) {
827829 const platformUrl = Utils . getPlatformUrl ( ) ;
828- const githubJobId = Utils . encodeForUrl ( process . env . GITHUB_JOB || '' ) ;
829- const gitRepo = Utils . encodeForUrl ( process . env . GITHUB_REPOSITORY || '' ) ;
830+ const githubJobId = this . getGithubJobId ( ) ;
831+ const gitRepo = process . env . GITHUB_REPOSITORY || '' ;
830832 const runId = process . env . GITHUB_RUN_ID || '' ;
831- return `` ;
832- }
833- static encodeForUrl ( value ) {
834- return encodeURIComponent ( value ) ;
833+ const url = new URL ( `${ platformUrl } ui/api/v1/u` ) ;
834+ url . searchParams . set ( Utils . SOURCE_PARAM_KEY , Utils . SOURCE_PARAM_VALUE ) ;
835+ url . searchParams . set ( Utils . METRIC_PARAM_KEY , Utils . METRIC_PARAM_VALUE ) ;
836+ url . searchParams . set ( Utils . JOB_ID_PARAM_KEY , githubJobId ) ;
837+ url . searchParams . set ( Utils . RUN_ID_PARAM_KEY , runId ) ;
838+ url . searchParams . set ( Utils . GIT_REPO_PARAM_KEY , gitRepo ) ;
839+ return ` } )` ;
835840 }
836841 /**
837842 * Checks if the header image is accessible via the internet.
@@ -872,6 +877,14 @@ class Utils {
872877 }
873878 return tempDir ;
874879 }
880+ /**
881+ * Retrieves the GitHub job ID, which in this context refers to the GitHub workflow name.
882+ * Note: We use "job" instead of "workflow" to align with our terminology, where "GitHub job summary"
883+ * refers to the entire workflow summary. Here, "job ID" means the workflow name, not individual jobs within the workflow.
884+ */
885+ static getGithubJobId ( ) {
886+ return process . env . GITHUB_WORKFLOW || '' ;
887+ }
875888}
876889exports . Utils = Utils ;
877890// eslint-disable-next-line @typescript-eslint/no-var-requires
@@ -939,3 +952,15 @@ Utils.CUSTOM_SERVER_ID = 'custom-server-id';
939952Utils . MARKDOWN_HEADER_PNG_URL = 'https://media.jfrog.com/wp-content/uploads/2024/09/02161430/jfrog-job-summary.svg' ;
940953// Flag to indicate if the summary header is accessible, can be undefined if not checked yet.
941954Utils . isSummaryHeaderAccessible = undefined ;
955+ // Job ID query parameter key
956+ Utils . JOB_ID_PARAM_KEY = 'job_id' ;
957+ // Run ID query parameter key
958+ Utils . RUN_ID_PARAM_KEY = 'run_id' ;
959+ // Git repository query parameter key
960+ Utils . GIT_REPO_PARAM_KEY = 'git_repo' ;
961+ // Source query parameter indicating the source of the request
962+ Utils . SOURCE_PARAM_KEY = 's' ;
963+ Utils . SOURCE_PARAM_VALUE = '1' ;
964+ // Metric query parameter indicating the metric type
965+ Utils . METRIC_PARAM_KEY = 'm' ;
966+ Utils . METRIC_PARAM_VALUE = '1' ;
0 commit comments