Skip to content

Commit b772214

Browse files
committed
add usage badge for summary
1 parent 3298827 commit b772214

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

lib/utils.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,9 @@ class Utils {
821821
return Utils.getMarkdownHeader() + fileContent + Utils.getMarkdownFooter();
822822
}
823823
static getMarkdownFooter() {
824-
return '\n\n # \n\n The above Job Summary was generated by the <a href="https://github.com/marketplace/actions/setup-jfrog-cli"> Setup JFrog CLI GitHub Action </a>';
824+
// Usage badge inserted at the end of the summary, in order to send usage data for the summary.
825+
const usageBadge = `![](${process.env.JF_URL}/ui/api/v1/u?s=1&m=1&job_id=${process.env.GITHUB_JOB}&run_id=${process.env.GITHUB_RUN_ID}&git_repo=${process.env.GITHUB_REPOSITORY})`;
826+
return `\n\n # \n\n ${usageBadge} \n\n The above Job Summary was generated by the <a href="https://github.com/marketplace/actions/setup-jfrog-cli"> Setup JFrog CLI GitHub Action </a>`;
825827
}
826828
static isHeaderPngAccessible() {
827829
return __awaiter(this, void 0, void 0, function* () {

src/utils.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -520,9 +520,9 @@ export class Utils {
520520
Utils.enableJobSummaries();
521521
}
522522

523-
Utils.setUsageEnvVars()
523+
Utils.setUsageEnvVars();
524524
}
525-
525+
526526
// Set usage variables to be captured by JFrog CLI visibility metric service.
527527
public static setUsageEnvVars(): void {
528528
// Set the GitHub repository name or default to an empty string.
@@ -906,7 +906,9 @@ export class Utils {
906906
}
907907

908908
private static getMarkdownFooter() {
909-
return '\n\n # \n\n The above Job Summary was generated by the <a href="https://github.com/marketplace/actions/setup-jfrog-cli"> Setup JFrog CLI GitHub Action </a>';
909+
// Usage badge inserted at the end of the summary, in order to send usage data for the summary.
910+
const usageBadge: string = `![](${process.env.JF_URL}/ui/api/v1/u?s=1&m=1&job_id=${process.env.GITHUB_JOB}&run_id=${process.env.GITHUB_RUN_ID}&git_repo=${process.env.GITHUB_REPOSITORY})`;
911+
return `\n\n # \n\n ${usageBadge} \n\n The above Job Summary was generated by the <a href="https://github.com/marketplace/actions/setup-jfrog-cli"> Setup JFrog CLI GitHub Action </a>`;
910912
}
911913

912914
private static async isHeaderPngAccessible(): Promise<boolean> {

test/main.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,6 @@ describe('Utils.removeJFrogServers', () => {
472472
});
473473
});
474474

475-
476475
describe('getApplicationKey', () => {
477476
const mockReadFile: jest.Mock = fs.promises.readFile as jest.Mock;
478477
const mockExistsSync: jest.Mock = fs.existsSync as jest.Mock;
@@ -568,4 +567,3 @@ describe('setUsageEnvVars', () => {
568567
expect(core.exportVariable).toHaveBeenCalledWith('JFROG_CLI_USAGE_GH_TOKEN_FOR_CODE_SCANNING_ALERTS_PROVIDED', false);
569568
});
570569
});
571-

0 commit comments

Comments
 (0)