Skip to content

Commit

Permalink
fix: report file path
Browse files Browse the repository at this point in the history
  • Loading branch information
bokuweb committed Nov 10, 2024
1 parent 6e95e2c commit ac2f27f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ The custom report page link.
- Type: String
- Default: N/A

Path of the generated report html file. This file can be deployed in other Actions steps, but is not included in the artifact. If omitted, no html report is generated.
Path of the generated report html file. This file can be deployed in other Actions steps, but is not included in the artifact. If omitted, treated as `./report.html`.

#### `artifact-name` (Optional)

Expand Down
17 changes: 8 additions & 9 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as core from '@actions/core';
import { statSync } from 'fs';
import { ARTIFACT_NAME } from './constants';
import { dirname } from 'path';
import { join } from 'path';

export interface Config {
imageDirectoryPath: string;
Expand Down Expand Up @@ -88,13 +88,6 @@ const validateReportFilePath = (path: string | undefined) => {
if (path === undefined || path === '') {
return;
}
try {
const s = statSync(dirname(path));
if (s.isDirectory()) return;
else throw null;
} catch (_) {
throw new Error(`'report-file-path' is not in a valid directory. Please specify path to report file.`);
}
};

function validateCommentReportFormat(format: string): asserts format is 'raw' | 'summarized' {
Expand Down Expand Up @@ -126,7 +119,13 @@ export const getConfig = (): Config => {
const branch = core.getInput('branch') || 'reg_actions';
const customReportPage = core.getInput('custom-report-page') || null;
validateCustomReportPage(customReportPage);
const reportFilePath = core.getInput('report-file-path') || './report.html';
let reportFilePath = core.getInput('report-file-path');
if (!reportFilePath) {
reportFilePath = './report.html';
}
if (statSync(reportFilePath).isDirectory()) {
reportFilePath = join(reportFilePath, './report.html')
}
validateReportFilePath(reportFilePath);
const commentReportFormat = core.getInput('comment-report-format') || 'raw';
validateCommentReportFormat(commentReportFormat);
Expand Down

0 comments on commit ac2f27f

Please sign in to comment.