Skip to content

Commit

Permalink
append-separator
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-evans committed Mar 31, 2023
1 parent 1ad97c8 commit 48d358e
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/comment-body-addition.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
**Edit:** Some additional info
This is still the second line.
5 changes: 1 addition & 4 deletions .github/comment-body.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
This is a multi-line test comment read from a file.
- With GitHub **Markdown** :sparkles:
- Created by [create-or-update-comment][1]

[1]: https://github.com/peter-evans/create-or-update-comment
This is the second line.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ jobs:
with:
comment-id: ${{ steps.couc2.outputs.comment-id }}
body-file: .github/comment-body-addition.md
append-separator: ' ' # space instead of newline
reactions: eyes, rocket

package:
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ inputs:
edit-mode:
description: 'The mode when updating a comment, "replace" or "append".'
default: 'append'
append-separator:
description: 'The separator to use when appending to an existing comment.'
default: '\n'
reactions:
description: 'A comma or newline separated list of reactions to add to the comment.'
outputs:
Expand Down
3 changes: 2 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ function createOrUpdateComment(inputs) {
repo: repo,
comment_id: inputs.commentId
});
commentBody = comment.body + '\n';
commentBody = comment.body + inputs.appendSeparator;
}
commentBody = commentBody + body;
core.debug(`Comment body: ${commentBody}`);
Expand Down Expand Up @@ -220,6 +220,7 @@ function run() {
body: core.getInput('body'),
bodyFile: core.getInput('body-file'),
editMode: core.getInput('edit-mode'),
appendSeparator: core.getInput('append-separator'),
reactions: utils.getInputAsArray('reactions')
};
core.debug(`Inputs: ${(0, util_1.inspect)(inputs)}`);
Expand Down
3 changes: 2 additions & 1 deletion src/create-or-update-comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface Inputs {
body: string
bodyFile: string
editMode: string
appendSeparator: string
reactions: string[]
}

Expand Down Expand Up @@ -105,7 +106,7 @@ export async function createOrUpdateComment(inputs: Inputs): Promise<void> {
repo: repo,
comment_id: inputs.commentId
})
commentBody = comment.body + '\n'
commentBody = comment.body + inputs.appendSeparator
}

commentBody = commentBody + body
Expand Down
1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ async function run(): Promise<void> {
body: core.getInput('body'),
bodyFile: core.getInput('body-file'),
editMode: core.getInput('edit-mode'),
appendSeparator: core.getInput('append-separator'),
reactions: utils.getInputAsArray('reactions')
}
core.debug(`Inputs: ${inspect(inputs)}`)
Expand Down

0 comments on commit 48d358e

Please sign in to comment.