@@ -191,8 +191,9 @@ class Utils {
191
191
const exchangeUrl = jfrogCredentials . jfrogUrl . replace ( / \/ $ / , '' ) + '/access/api/v1/oidc/token' ;
192
192
core . debug ( 'Exchanging GitHub JSON web token with a JFrog access token...' ) ;
193
193
let projectKey = process . env . JF_PROJECT || '' ;
194
- let jobId = process . env . GITHUB_JOB || '' ;
194
+ let jobId = this . getGithubJobId ( ) ;
195
195
let runId = process . env . GITHUB_RUN_ID || '' ;
196
+ let githubRepository = process . env . GITHUB_REPOSITORY || '' ;
196
197
const httpClient = new http_client_1 . HttpClient ( ) ;
197
198
const data = `{
198
199
"grant_type": "urn:ietf:params:oauth:grant-type:token-exchange",
@@ -202,6 +203,7 @@ class Utils {
202
203
"project_key": "${ projectKey } ",
203
204
"gh_job_id": "${ jobId } ",
204
205
"gh_run_id": "${ runId } ",
206
+ "gh_repo": "${ githubRepository } ",
205
207
"application_key": "${ applicationKey } "
206
208
}` ;
207
209
const additionalHeaders = {
@@ -825,13 +827,16 @@ class Utils {
825
827
}
826
828
static getUsageBadge ( ) {
827
829
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 || '' ;
830
832
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 ` } )` ;
835
840
}
836
841
/**
837
842
* Checks if the header image is accessible via the internet.
@@ -872,6 +877,14 @@ class Utils {
872
877
}
873
878
return tempDir ;
874
879
}
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
+ }
875
888
}
876
889
exports . Utils = Utils ;
877
890
// eslint-disable-next-line @typescript-eslint/no-var-requires
@@ -939,3 +952,15 @@ Utils.CUSTOM_SERVER_ID = 'custom-server-id';
939
952
Utils . MARKDOWN_HEADER_PNG_URL = 'https://media.jfrog.com/wp-content/uploads/2024/09/02161430/jfrog-job-summary.svg' ;
940
953
// Flag to indicate if the summary header is accessible, can be undefined if not checked yet.
941
954
Utils . 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