Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix summary header image not loading #192

Merged
merged 8 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified images/job_summary.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/summary_header.png
Binary file not shown.
2 changes: 0 additions & 2 deletions lib/cleanup.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ function cleanup() {
// Auto-publish build info if needed
try {
if (!core.getBooleanInput(utils_1.Utils.AUTO_BUILD_PUBLISH_DISABLE)) {
core.startGroup('Build Info Auto-Publish');
yield collectAndPublishBuildInfoIfNeeded();
core.endGroup();
}
}
catch (error) {
Expand Down
13 changes: 8 additions & 5 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -519,17 +519,17 @@ class Utils {
}
static readMarkdownContent() {
return __awaiter(this, void 0, void 0, function* () {
const outputDir = Utils.getJobOutputDirectoryPath();
if ((0, fs_1.existsSync)(outputDir)) {
return yield fs_1.promises.readFile(path.join(outputDir, 'markdown.md'), 'utf-8');
const markdownFilePath = path.join(Utils.getJobOutputDirectoryPath(), 'markdown.md');
if ((0, fs_1.existsSync)(markdownFilePath)) {
return yield fs_1.promises.readFile(markdownFilePath, 'utf-8');
}
return '';
});
}
static getMarkdownHeader() {
let mainTitle;
if (this.isSummaryHeaderAccessible) {
mainTitle = `<picture><img alt="Summary-Header" src=${this.MARKDOWN_HEADER_PNG_URL}></picture>` + '\n\n';
mainTitle = `![JFrog Job Summary Header](${this.MARKDOWN_HEADER_PNG_URL})` + '\n\n';
}
else {
mainTitle = `# 🐸 JFrog Job Summary` + '\n\n';
Expand Down Expand Up @@ -634,5 +634,8 @@ Utils.OIDC_INTEGRATION_PROVIDER_NAME = 'oidc-provider-name';
Utils.JOB_SUMMARY_DISABLE = 'disable-job-summary';
// Disable auto build info publish feature flag
Utils.AUTO_BUILD_PUBLISH_DISABLE = 'disable-auto-build-publish';
// Source URL holding the markdown header image
// URL for the markdown header image
// This is hosted statically because its usage is outside the context of the JFrog setup action.
// It cannot be linked to the repository, as GitHub serves the image from a CDN,
// which gets blocked by the browser, resulting in an empty image.
Utils.MARKDOWN_HEADER_PNG_URL = 'https://media.jfrog.com/wp-content/uploads/2024/09/01120106/summary_header.png';
2 changes: 0 additions & 2 deletions src/cleanup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ async function cleanup() {
// Auto-publish build info if needed
try {
if (!core.getBooleanInput(Utils.AUTO_BUILD_PUBLISH_DISABLE)) {
core.startGroup('Build Info Auto-Publish');
await collectAndPublishBuildInfoIfNeeded();
core.endGroup();
}
} catch (error) {
core.warning('failed while attempting to publish build info: ' + error);
Expand Down
13 changes: 8 additions & 5 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ export class Utils {
public static readonly JOB_SUMMARY_DISABLE: string = 'disable-job-summary';
// Disable auto build info publish feature flag
public static readonly AUTO_BUILD_PUBLISH_DISABLE: string = 'disable-auto-build-publish';
// Source URL holding the markdown header image
// URL for the markdown header image
// This is hosted statically because its usage is outside the context of the JFrog setup action.
// It cannot be linked to the repository, as GitHub serves the image from a CDN,
// which gets blocked by the browser, resulting in an empty image.
private static MARKDOWN_HEADER_PNG_URL: string = 'https://media.jfrog.com/wp-content/uploads/2024/09/01120106/summary_header.png';
private static isSummaryHeaderAccessible: boolean;

Expand Down Expand Up @@ -568,17 +571,17 @@ export class Utils {
}

private static async readMarkdownContent() {
const outputDir: string = Utils.getJobOutputDirectoryPath();
if (existsSync(outputDir)) {
return await fs.readFile(path.join(outputDir, 'markdown.md'), 'utf-8');
const markdownFilePath: string = path.join(Utils.getJobOutputDirectoryPath(), 'markdown.md');
if (existsSync(markdownFilePath)) {
return await fs.readFile(markdownFilePath, 'utf-8');
}
return '';
}

private static getMarkdownHeader(): string {
let mainTitle: string;
if (this.isSummaryHeaderAccessible) {
mainTitle = `<picture><img alt="Summary-Header" src=${this.MARKDOWN_HEADER_PNG_URL}></picture>` + '\n\n';
mainTitle = `![JFrog Job Summary Header](${this.MARKDOWN_HEADER_PNG_URL})` + '\n\n';
} else {
mainTitle = `# 🐸 JFrog Job Summary` + '\n\n';
}
Expand Down
Loading