diff --git a/README.md b/README.md index d35622d..17faa97 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,8 @@ You can find all the inputs in [the action file](./action.yml) but let's walk th - `noComments`: Boolean. If the action should only fetch Pull Requests that have 0 reviews (comments do not count). - Short for `Ignore PRs that have comments`. - **default**: false +- `fileOutput`: String. File to which the output from `data` should be written. + - Useful in the cases where the output is too big and GitHub Actions can not handle it as a variable. #### Accessing other repositories diff --git a/action.yml b/action.yml index 5471c24..b27640c 100644 --- a/action.yml +++ b/action.yml @@ -22,6 +22,9 @@ inputs: required: false description: If true, it will only collect PRs with NO reviews. default: false + fileOutput: + required: false + description: File to which the output data should be written. outputs: repo: description: 'The name of the repo in owner/repo pattern' @@ -34,4 +37,4 @@ outputs: runs: using: 'docker' - image: 'docker://ghcr.io/paritytech/stale-pr-finder/action:0.0.1' + image: 'docker://ghcr.io/paritytech/stale-pr-finder/action:0.0.2' diff --git a/package.json b/package.json index cd5886e..3089edb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "stale-pr-finder", - "version": "0.0.1", + "version": "0.0.2", "description": "GitHub action that finds stale PRs and produce an output with them", "main": "src/index.ts", "scripts": { diff --git a/src/index.ts b/src/index.ts index 3b324e1..1fb2024 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,8 @@ -import { debug, getBooleanInput, getInput, info, setOutput, summary } from "@actions/core"; +import { debug, getBooleanInput, getInput, info, setFailed, setOutput, summary } from "@actions/core"; import { context } from "@actions/github"; import { Context } from "@actions/github/lib/context"; import { github } from "@eng-automation/integrations"; +import { writeFile } from "fs"; import moment from "moment"; import { byNoReviews, olderThanDays } from "./filters"; import { getPullRequestWithReviews } from "./githubApi"; @@ -72,6 +73,7 @@ const runAction = async (ctx: Context) => { const inputDays = Number.parseInt(getInput("days-stale", { required: false })); const daysStale = isNaN(inputDays) ? 5 : inputDays; const stale = isNaN(daysStale); + const outputFile = getInput("fileOutput", { required: false }); console.log("daysStale", daysStale, stale); const octokit = await github.getInstance({ authType: "token", authToken: token }) @@ -103,6 +105,14 @@ const runAction = async (ctx: Context) => { const message = generateMarkdownMessage(filterReviews, repo); setOutput("message", message); + if (outputFile) { + writeFile(outputFile, jsonData, err => { + if (err) { + setFailed(err); + } + }) + } + await summary.addHeading(`${repo.owner}/${repo.repo}`) .addHeading(`${amountOfStalePrs} stale PRs`, 3) .addTable([