diff --git a/.gitignore b/.gitignore index fd4437e9e..1d7717561 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /*.js.map /examples +/test diff --git a/action.yml b/action.yml index 558b7be2c..02e08c231 100644 --- a/action.yml +++ b/action.yml @@ -18,9 +18,12 @@ inputs: required: true default: 'gh-pages' benchmark-data-dir-path: - description: 'Path to directory which contains JSON files benchmarks' + description: 'Path to directory which contains benchmark files on GitHub pages branch' required: true default: 'dev/bench' + github-token: + description: 'GitHub API token to pull/push GitHub pages branch and deploy GitHub pages' + required: false runs: using: 'node12' diff --git a/config.js b/config.js index 779e8cf87..5a829f075 100644 --- a/config.js +++ b/config.js @@ -69,18 +69,29 @@ function validateName(name) { } throw new Error('Name must not be empty'); } +function validateAutoPush(autoPush, githubToken) { + if (!autoPush) { + return; + } + if (!githubToken) { + throw new Error("'auto-push' is enabled but 'github-token' is not set. Please give API token for pushing GitHub pages branch to remote"); + } +} async function configFromJobInput() { const tool = core.getInput('tool'); let outputFilePath = core.getInput('output-file-path'); const ghPagesBranch = core.getInput('gh-pages-branch'); let benchmarkDataDirPath = core.getInput('benchmark-data-dir-path'); const name = core.getInput('name'); + const githubToken = core.getInput('github-token') || undefined; + const autoPush = core.getInput('auto-push') === 'true'; validateToolType(tool); outputFilePath = await validateOutputFilePath(outputFilePath); validateGhPagesBranch(ghPagesBranch); benchmarkDataDirPath = validateBenchmarkDataDirPath(benchmarkDataDirPath); validateName(name); - return { name, tool, outputFilePath, ghPagesBranch, benchmarkDataDirPath }; + validateAutoPush(autoPush, githubToken); + return { name, tool, outputFilePath, ghPagesBranch, benchmarkDataDirPath, githubToken, autoPush }; } exports.configFromJobInput = configFromJobInput; -//# sourceMappingURL=config.js.map \ No newline at end of file +//# sourceMappingURL=config.js.map diff --git a/default_index_html.js b/default_index_html.js index c4c474783..da25d6818 100644 --- a/default_index_html.js +++ b/default_index_html.js @@ -89,7 +89,7 @@ exports.DEFAULT_INDEX_HTML = String.raw ` -