Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add create_comment_for_each_run option #94

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@ with:
package_manager: yarn
```

### Creating PR comment for each run

By default, if the action is run multiple times, it will update the same comment. If you want to create a new comment for each run, you can set the `create_comment_for_each_run` option to `true`.

```yaml
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
create_comment_for_each_run: true
```

## Feedback

Pull requests, feature ideas and bug reports are very welcome. We highly appreciate any feedback.
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ inputs:
package_manager:
required: false
description: "The package manager used to run the build and install commands. If not provided, the manager will be auto detected. Example values: `yarn`, `npm`, `pnpm`."
create_comment_for_each_run:
required: false
description: "If true, create a new comment for each run. If false (default), the action will update the previous comment."
runs:
using: 'node12'
main: 'dist/index.js'
3 changes: 2 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3845,6 +3845,7 @@ function run() {
const packageManager = core_1.getInput("package_manager");
const directory = core_1.getInput("directory") || process.cwd();
const windowsVerbatimArguments = core_1.getInput("windows_verbatim_arguments") === "true" ? true : false;
const createCommentForEachRun = core_1.getInput("create_comment_for_each_run") === "true" ? true : false;
const octokit = new github_1.GitHub(token);
const term = new Term_1.default();
const limit = new SizeLimit_1.default();
Expand All @@ -3865,7 +3866,7 @@ function run() {
markdown_table_1.default(limit.formatResults(base, current))
].join("\r\n");
const sizeLimitComment = yield fetchPreviousComment(octokit, repo, pr);
if (!sizeLimitComment) {
if (!sizeLimitComment || createCommentForEachRun) {
try {
yield octokit.issues.createComment(Object.assign(Object.assign({}, repo), {
// eslint-disable-next-line camelcase
Expand Down
4 changes: 3 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ async function run() {
const directory = getInput("directory") || process.cwd();
const windowsVerbatimArguments =
getInput("windows_verbatim_arguments") === "true" ? true : false;
const createCommentForEachRun =
getInput("create_comment_for_each_run") === "true" ? true : false;
const octokit = new GitHub(token);
const term = new Term();
const limit = new SizeLimit();
Expand Down Expand Up @@ -93,7 +95,7 @@ async function run() {

const sizeLimitComment = await fetchPreviousComment(octokit, repo, pr);

if (!sizeLimitComment) {
if (!sizeLimitComment || createCommentForEachRun) {
try {
await octokit.issues.createComment({
...repo,
Expand Down