Skip to content

Commit

Permalink
added JSON file output, fixes: #110
Browse files Browse the repository at this point in the history
  • Loading branch information
gautamkrishnar committed Nov 30, 2021
1 parent 5ddca49 commit 163d740
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ This workflow has additional options that you can use to customize it for your u
| `commit_message` | `Updated with the latest blog posts` | Allows you to customize the commit message | No |
| `committer_username` | `blog-post-bot` | Allows you to customize the committer username | No |
| `committer_email` | `[email protected]` | Allows you to customize the committer email | No |
| `output_only` | `false` | Sets the generated array as `results` [output variable](https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#jobsjob_idoutputs) so that it can be consumed in other actions and parsed via utilities like [jq](https://stedolan.github.io/jq/). This will also prevent committing to readme. See [#51](https://github.com/gautamkrishnar/blog-post-workflow/issues/51#issuecomment-758570235) for more details about the output format and how to use it. | No |
| `output_only` | `false` | Sets the generated array as `results` [output variable](https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#jobsjob_idoutputs) so that it can be consumed in other actions and parsed via utilities like [jq](https://stedolan.github.io/jq/). This will also prevent committing to readme. See [#51](https://github.com/gautamkrishnar/blog-post-workflow/issues/51#issuecomment-758570235) for more details about the output format and how to use it. This will also generate a JSON file named `/tmp/blog_post_workflow_output.json` that you can use to consume the generated data and avoid issues like [#110](https://github.com/gautamkrishnar/blog-post-workflow/issues/110). | No |
| `enable_keepalive` | `true` | Workflow will automatically do a dummy commit to keep the repository active if there is no commit activity for the last 50 days. GitHub will stop running all cron based triggers if the repository is not active for more than 60 days. This flag allows you to disable this feature. See [#53](https://git.io/Jtm4V) for more details. | No |
| `retry_count` | `0` | Maximum number of times to retry the fetch operation if it fails, See [#66](https://github.com/gautamkrishnar/blog-post-workflow/issues/66) for more details. | No |
| `retry_wait_time` | `1` | Time to wait before each retry operation in seconds. | No |
Expand Down
6 changes: 6 additions & 0 deletions blog-post-workflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const {
ignoreMediumComments,
ignoreStackOverflowComments
} = require('./filters');
const path = require("path");

// Blog workflow code
const userAgent = core.getInput('user_agent');
Expand Down Expand Up @@ -290,6 +291,11 @@ Promise.allSettled(promiseArray).then((results) => {
// Sets output as output as `results` variable in github action
core.info('outputOnly mode: set `results` variable. Readme not committed.');
core.setOutput('results', postsArray);
const outputFilePath = path.join('/','tmp', 'blog_post_workflow_output.json');
if(fs.existsSync(outputFilePath)) {
fs.rmSync(outputFilePath);
}
fs.writeFileSync(outputFilePath, postsArray, { encoding: 'utf-8'});
process.exit(jobFailFlag ? 1 : 0);
}

Expand Down

0 comments on commit 163d740

Please sign in to comment.