Skip to content

Commit 48d358e

Browse files
committed
append-separator
1 parent 1ad97c8 commit 48d358e

File tree

7 files changed

+11
-7
lines changed

7 files changed

+11
-7
lines changed

.github/comment-body-addition.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
**Edit:** Some additional info
1+
This is still the second line.

.github/comment-body.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
11
This is a multi-line test comment read from a file.
2-
- With GitHub **Markdown** :sparkles:
3-
- Created by [create-or-update-comment][1]
4-
5-
[1]: https://github.com/peter-evans/create-or-update-comment
2+
This is the second line.

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ jobs:
112112
with:
113113
comment-id: ${{ steps.couc2.outputs.comment-id }}
114114
body-file: .github/comment-body-addition.md
115+
append-separator: ' ' # space instead of newline
115116
reactions: eyes, rocket
116117

117118
package:

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ inputs:
1818
edit-mode:
1919
description: 'The mode when updating a comment, "replace" or "append".'
2020
default: 'append'
21+
append-separator:
22+
description: 'The separator to use when appending to an existing comment.'
23+
default: '\n'
2124
reactions:
2225
description: 'A comma or newline separated list of reactions to add to the comment.'
2326
outputs:

dist/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ function createOrUpdateComment(inputs) {
118118
repo: repo,
119119
comment_id: inputs.commentId
120120
});
121-
commentBody = comment.body + '\n';
121+
commentBody = comment.body + inputs.appendSeparator;
122122
}
123123
commentBody = commentBody + body;
124124
core.debug(`Comment body: ${commentBody}`);
@@ -220,6 +220,7 @@ function run() {
220220
body: core.getInput('body'),
221221
bodyFile: core.getInput('body-file'),
222222
editMode: core.getInput('edit-mode'),
223+
appendSeparator: core.getInput('append-separator'),
223224
reactions: utils.getInputAsArray('reactions')
224225
};
225226
core.debug(`Inputs: ${(0, util_1.inspect)(inputs)}`);

src/create-or-update-comment.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export interface Inputs {
1010
body: string
1111
bodyFile: string
1212
editMode: string
13+
appendSeparator: string
1314
reactions: string[]
1415
}
1516

@@ -105,7 +106,7 @@ export async function createOrUpdateComment(inputs: Inputs): Promise<void> {
105106
repo: repo,
106107
comment_id: inputs.commentId
107108
})
108-
commentBody = comment.body + '\n'
109+
commentBody = comment.body + inputs.appendSeparator
109110
}
110111

111112
commentBody = commentBody + body

src/main.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ async function run(): Promise<void> {
1414
body: core.getInput('body'),
1515
bodyFile: core.getInput('body-file'),
1616
editMode: core.getInput('edit-mode'),
17+
appendSeparator: core.getInput('append-separator'),
1718
reactions: utils.getInputAsArray('reactions')
1819
}
1920
core.debug(`Inputs: ${inspect(inputs)}`)

0 commit comments

Comments
 (0)