diff --git a/README.md b/README.md index 4a9a023..b6880cb 100644 --- a/README.md +++ b/README.md @@ -72,5 +72,15 @@ with: working-directory: "frontend" ``` +### Process jest result and publish + +```yaml +uses: mattallty/jest-github-action@v1 +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +with: + process-only: true + results-file: "jest.results.json" +``` See the [actions tab](https://github.com/mattallty/jest-github-action/actions) for runs of this action! :rocket: diff --git a/action.yml b/action.yml index 701066d..bd0e38f 100644 --- a/action.yml +++ b/action.yml @@ -4,6 +4,14 @@ branding: icon: "check" color: "blue" inputs: + process-only: + description: "Only process the result file" + required: false + default: "false" + results-file: + description: "Filename for the jest result file" + required: false + default: "jest.results.json" test-command: description: "The test command to run" required: false diff --git a/src/action.ts b/src/action.ts index e8e049f..549f2ba 100644 --- a/src/action.ts +++ b/src/action.ts @@ -18,9 +18,12 @@ const COVERAGE_HEADER = ":loop: **Code coverage**\n\n" export async function run() { let workingDirectory = core.getInput("working-directory", { required: false }) let cwd = workingDirectory ? resolve(workingDirectory) : process.cwd() - const CWD = cwd + sep - const RESULTS_FILE = join(CWD, "jest.results.json") + const resultFileName = core.getInput("results-file", { required: false }) || "jest.results.json" + let processOnly = core.getInput("process-only", { required: false }) + const CWD = cwd + sep + const RESULTS_FILE = join(CWD, resultFileName) + try { const token = process.env.GITHUB_TOKEN if (token === undefined) { @@ -29,9 +32,14 @@ export async function run() { return } - const cmd = getJestCommand(RESULTS_FILE) + if (processOnly === "true") { + console.log("Processing file: " + RESULTS_FILE) + } else { + const cmd = getJestCommand(RESULTS_FILE) - await execJest(cmd, CWD) + await execJest(cmd, CWD) + + } // octokit const octokit = new GitHub(token)