Skip to content

Commit

Permalink
Merge pull request #890 from WebFreak001/only_create-setting
Browse files Browse the repository at this point in the history
add setting to only create, but not update comment
  • Loading branch information
marocchino authored Feb 9, 2023
2 parents 2524231 + 42ddbbd commit 4608256
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 193 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ is explicitly passed, this problem can be solved by just removing it.

**Optional** Delete a previously created comment. Use `header` to point to which comment you want to delete. Only `true` is allowed (i.e. delete this option if you don't need it).

### `only_create`

**Optional** Only create a new comment if there is no existing one, otherwise do nothing. Only `true` is allowed. Just skip this item when you don't need it.

### `hide`

**Optional** Hide a previously created comment. Use `header` to point to which comment you want to delete. Only `true` is allowed (i.e. delete this option if you don't need it).
Expand Down
2 changes: 2 additions & 0 deletions __tests__/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ beforeEach(() => {
process.env["INPUT_APPEND"] = "false"
process.env["INPUT_RECREATE"] = "false"
process.env["INPUT_DELETE"] = "false"
process.env["INPUT_ONLY_CREATE"] = "false"
process.env["INPUT_HIDE"] = "false"
process.env["INPUT_HIDE_AND_RECREATE"] = "false"
process.env["INPUT_HIDE_CLASSIFY"] = "OUTDATED"
Expand All @@ -23,6 +24,7 @@ afterEach(() => {
delete process.env["INPUT_APPEND"]
delete process.env["INPUT_RECREATE"]
delete process.env["INPUT_DELETE"]
delete process.env["INPUT_ONLY_CREATE"]
delete process.env["INPUT_HIDE"]
delete process.env["INPUT_HIDE_AND_RECREATE"]
delete process.env["INPUT_HIDE_CLASSIFY"]
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ inputs:
description: "delete the previously created comment. Only `true` is allowed. Just skip this item when you don't need it."
default: "false"
required: false
only_create:
description: "only create a new comment if there is no existing one, otherwise do nothing. Only `true` is allowed. Just skip this item when you don't need it. This options has higher priority than hide_and_recreate, hide."
default: "false"
required: false
hide_details:
description: "hide summary tags in the previously created comment. Only `true` is allowed. Just skip this item when you don't need it."
default: "false"
Expand Down
209 changes: 18 additions & 191 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ export const hideClassify = core.getInput("hide_classify", {
required: true
}) as ReportedContentClassifiers
export const deleteOldComment = core.getBooleanInput("delete", {required: true})
export const onlyCreateComment = core.getBooleanInput("only_create", {
required: true
})
export const hideOldComment = core.getBooleanInput("hide", {required: true})
export const githubToken = core.getInput("GITHUB_TOKEN", {required: true})
export const ignoreEmpty = core.getBooleanInput("ignore_empty", {
Expand Down
9 changes: 8 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import {
pullRequestNumber,
recreate,
repo,
ignoreEmpty
ignoreEmpty,
onlyCreateComment
} from "./config"
import {
createComment,
Expand Down Expand Up @@ -70,6 +71,12 @@ async function run(): Promise<undefined> {
return
}

if (onlyCreateComment) {
// don't comment anything, user specified only_create and there is an
// existing comment, so this is probably a placeholder / introduction one.
return
}

if (hideOldComment) {
await minimizeComment(octokit, previous.id, hideClassify)
return
Expand Down

0 comments on commit 4608256

Please sign in to comment.