Skip to content

Commit 3383acd

Browse files
authored
v3 (#161)
* typescript * fix reactions input * test comma separated * bump version * append-separator * refactor * refactor reactions * get reactions * handle default token * return reaction id * remove reactions * reactions-edit-mode * readme * test-command * fix step order * deprecate body-file * update ci to body-path
1 parent 9c63576 commit 3383acd

21 files changed

+3654
-5531
lines changed

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dist/
2+
lib/
3+
node_modules/

.eslintrc.json

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
{
2-
"env": {
3-
"commonjs": true,
4-
"es6": true,
5-
"node": true
6-
},
7-
"extends": "eslint:recommended",
8-
"globals": {
9-
"Atomics": "readonly",
10-
"SharedArrayBuffer": "readonly"
11-
},
12-
"parserOptions": {
13-
"ecmaVersion": 2018
14-
},
15-
"rules": {
16-
}
17-
}
2+
"env": { "node": true, "jest": true },
3+
"parser": "@typescript-eslint/parser",
4+
"parserOptions": { "ecmaVersion": 9, "sourceType": "module" },
5+
"extends": [
6+
"eslint:recommended",
7+
"plugin:@typescript-eslint/eslint-recommended",
8+
"plugin:@typescript-eslint/recommended",
9+
"plugin:import/errors",
10+
"plugin:import/warnings",
11+
"plugin:import/typescript",
12+
"plugin:prettier/recommended"
13+
],
14+
"plugins": ["@typescript-eslint"],
15+
"rules": {
16+
"@typescript-eslint/camelcase": "off"
17+
}
18+
}

.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: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ jobs:
2828
node-version: 16.x
2929
cache: npm
3030
- run: npm ci
31+
- run: npm run build
32+
- run: npm run format-check
33+
- run: npm run lint
3134
- run: npm run test
32-
- run: npm run package
3335
- uses: actions/upload-artifact@v3
3436
with:
3537
name: dist
@@ -86,27 +88,34 @@ jobs:
8688
body: |
8789
**Edit:** Some additional info
8890
reactions: eyes
91+
reactions-edit-mode: replace
8992

9093
- name: Test add reactions
9194
uses: ./
9295
with:
9396
comment-id: ${{ steps.couc.outputs.comment-id }}
94-
reactions: heart, hooray, laugh
97+
reactions: |
98+
heart
99+
hooray
100+
laugh
95101
96102
- name: Test create comment from file
97103
uses: ./
98104
id: couc2
99105
with:
100106
issue-number: ${{ needs.build.outputs.issue-number }}
101-
body-file: .github/comment-body.md
102-
reactions: '+1'
107+
body-path: .github/comment-body.md
108+
reactions: |
109+
+1
103110
104111
- name: Test update comment from file
105112
uses: ./
106113
with:
107114
comment-id: ${{ steps.couc2.outputs.comment-id }}
108-
body-file: .github/comment-body-addition.md
109-
reactions: eyes
115+
body-path: .github/comment-body-addition.md
116+
append-separator: space
117+
reactions: eyes, rocket
118+
reactions-edit-mode: replace
110119

111120
package:
112121
if: github.event_name == 'push' && github.ref == 'refs/heads/main'

.github/workflows/test-command.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ jobs:
4545
body: |
4646
**Edit:** Some additional info
4747
reactions: eyes
48+
reactions-edit-mode: replace
4849

4950
# Test add reactions
5051
- name: Add reactions
@@ -53,19 +54,12 @@ jobs:
5354
comment-id: ${{ steps.couc.outputs.comment-id }}
5455
reactions: heart, hooray, laugh
5556

56-
- name: Add reaction
57-
uses: peter-evans/create-or-update-comment@v2
58-
with:
59-
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
60-
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
61-
reactions: hooray
62-
6357
# Test create with body from file
6458
- name: Create comment
6559
uses: ./
6660
with:
6761
issue-number: 1
68-
body-file: .github/comment-body.md
62+
body-path: .github/comment-body.md
6963

7064
# Test create from template
7165
- name: Render template
@@ -82,3 +76,10 @@ jobs:
8276
with:
8377
issue-number: 1
8478
body: ${{ steps.template.outputs.result }}
79+
80+
- name: Add reaction
81+
uses: peter-evans/create-or-update-comment@v2
82+
with:
83+
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
84+
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
85+
reactions: hooray

.github/workflows/update-major-version.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ on:
1212
description: The major version tag to update
1313
options:
1414
- v2
15+
- v3
1516

1617
jobs:
1718
tag:

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
node_modules
1+
lib/
2+
node_modules/

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dist/
2+
lib/
3+
node_modules/

.prettierrc.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"printWidth": 80,
3+
"tabWidth": 2,
4+
"useTabs": false,
5+
"semi": false,
6+
"singleQuote": true,
7+
"trailingComma": "none",
8+
"bracketSpacing": false,
9+
"arrowParens": "avoid",
10+
"parser": "typescript"
11+
}

README.md

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44

55
A GitHub action to create or update an issue or pull request comment.
66

7-
This action was created to help facilitate a GitHub Actions "ChatOps" solution in conjunction with [slash-command-dispatch](https://github.com/peter-evans/slash-command-dispatch) action.
8-
97
## Usage
108

119
### Add a comment to an issue or pull request
1210

1311
```yml
1412
- name: Create comment
15-
uses: peter-evans/create-or-update-comment@v2
13+
uses: peter-evans/create-or-update-comment@v3
1614
with:
1715
issue-number: 1
1816
body: |
@@ -28,7 +26,7 @@ This action was created to help facilitate a GitHub Actions "ChatOps" solution i
2826
2927
```yml
3028
- name: Update comment
31-
uses: peter-evans/create-or-update-comment@v2
29+
uses: peter-evans/create-or-update-comment@v3
3230
with:
3331
comment-id: 557858210
3432
body: |
@@ -40,10 +38,13 @@ This action was created to help facilitate a GitHub Actions "ChatOps" solution i
4038
4139
```yml
4240
- name: Add reactions
43-
uses: peter-evans/create-or-update-comment@v2
41+
uses: peter-evans/create-or-update-comment@v3
4442
with:
4543
comment-id: 557858210
46-
reactions: heart, hooray, laugh
44+
reactions: |
45+
heart
46+
hooray
47+
laugh
4748
```
4849
4950
### Action inputs
@@ -54,10 +55,12 @@ This action was created to help facilitate a GitHub Actions "ChatOps" solution i
5455
| `repository` | The full name of the repository in which to create or update a comment. | Current repository |
5556
| `issue-number` | The number of the issue or pull request in which to create a comment. | |
5657
| `comment-id` | The id of the comment to update. | |
57-
| `body` | The comment body. Cannot be used in conjunction with `body-file`. | |
58-
| `body-file` | The path to a file containing the comment body. Cannot be used in conjunction with `body`. | |
58+
| `body` | The comment body. Cannot be used in conjunction with `body-path`. | |
59+
| `body-path` | The path to a file containing the comment body. Cannot be used in conjunction with `body`. | |
5960
| `edit-mode` | The mode when updating a comment, `replace` or `append`. | `append` |
60-
| `reactions` | A comma separated list of reactions to add to the comment. (`+1`, `-1`, `laugh`, `confused`, `heart`, `hooray`, `rocket`, `eyes`) | |
61+
| `append-separator` | The separator to use when appending to an existing comment. (`newline`, `space`, `none`) | `newline` |
62+
| `reactions` | A comma or newline separated list of reactions to add to the comment. (`+1`, `-1`, `laugh`, `confused`, `heart`, `hooray`, `rocket`, `eyes`) | |
63+
| `reactions-edit-mode` | The mode when updating comment reactions, `replace` or `append`. | `append` |
6164

6265
Note: In *public* repositories this action does not work in `pull_request` workflows when triggered by forks.
6366
Any attempt will be met with the error, `Resource not accessible by integration`.
@@ -70,7 +73,7 @@ Note that in order to read the step output the action step must have an id.
7073

7174
```yml
7275
- name: Create comment
73-
uses: peter-evans/create-or-update-comment@v2
76+
uses: peter-evans/create-or-update-comment@v3
7477
id: couc
7578
with:
7679
issue-number: 1
@@ -95,7 +98,7 @@ jobs:
9598
runs-on: ubuntu-latest
9699
steps:
97100
- name: Add reaction
98-
uses: peter-evans/create-or-update-comment@v2
101+
uses: peter-evans/create-or-update-comment@v3
99102
with:
100103
comment-id: ${{ github.event.comment.id }}
101104
reactions: eyes
@@ -110,15 +113,15 @@ If the find-comment action output `comment-id` returns an empty string, a new co
110113
If it returns a value, the comment already exists and the content is replaced.
111114
```yml
112115
- name: Find Comment
113-
uses: peter-evans/find-comment@v2
116+
uses: peter-evans/find-comment@v3
114117
id: fc
115118
with:
116119
issue-number: ${{ github.event.pull_request.number }}
117120
comment-author: 'github-actions[bot]'
118121
body-includes: Build output
119122
120123
- name: Create or update comment
121-
uses: peter-evans/create-or-update-comment@v2
124+
uses: peter-evans/create-or-update-comment@v3
122125
with:
123126
comment-id: ${{ steps.fc.outputs.comment-id }}
124127
issue-number: ${{ github.event.pull_request.number }}
@@ -131,7 +134,7 @@ If it returns a value, the comment already exists and the content is replaced.
131134
If required, the create and update steps can be separated for greater control.
132135
```yml
133136
- name: Find Comment
134-
uses: peter-evans/find-comment@v2
137+
uses: peter-evans/find-comment@v3
135138
id: fc
136139
with:
137140
issue-number: ${{ github.event.pull_request.number }}
@@ -140,7 +143,7 @@ If required, the create and update steps can be separated for greater control.
140143
141144
- name: Create comment
142145
if: steps.fc.outputs.comment-id == ''
143-
uses: peter-evans/create-or-update-comment@v2
146+
uses: peter-evans/create-or-update-comment@v3
144147
with:
145148
issue-number: ${{ github.event.pull_request.number }}
146149
body: |
@@ -149,7 +152,7 @@ If required, the create and update steps can be separated for greater control.
149152
150153
- name: Update comment
151154
if: steps.fc.outputs.comment-id != ''
152-
uses: peter-evans/create-or-update-comment@v2
155+
uses: peter-evans/create-or-update-comment@v3
153156
with:
154157
comment-id: ${{ steps.fc.outputs.comment-id }}
155158
body: |
@@ -161,10 +164,10 @@ If required, the create and update steps can be separated for greater control.
161164

162165
```yml
163166
- name: Create comment
164-
uses: peter-evans/create-or-update-comment@v2
167+
uses: peter-evans/create-or-update-comment@v3
165168
with:
166169
issue-number: 1
167-
body-file: 'comment-body.md'
170+
body-path: 'comment-body.md'
168171
```
169172

170173
### Using a markdown template
@@ -187,7 +190,7 @@ The template is rendered using the [render-template](https://github.com/chuhlomi
187190
bar: that
188191
189192
- name: Create comment
190-
uses: peter-evans/create-or-update-comment@v2
193+
uses: peter-evans/create-or-update-comment@v3
191194
with:
192195
issue-number: 1
193196
body: ${{ steps.template.outputs.result }}

action.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,28 @@ inputs:
66
default: ${{ github.token }}
77
repository:
88
description: 'The full name of the repository in which to create or update a comment.'
9+
default: ${{ github.repository }}
910
issue-number:
1011
description: 'The number of the issue or pull request in which to create a comment.'
1112
comment-id:
1213
description: 'The id of the comment to update.'
1314
body:
14-
description: 'The comment body. Cannot be used in conjunction with `body-file`.'
15-
body-file:
15+
description: 'The comment body. Cannot be used in conjunction with `body-path`.'
16+
body-path:
1617
description: 'The path to a file containing the comment body. Cannot be used in conjunction with `body`.'
18+
body-file:
19+
description: 'Deprecated in favour of `body-path`.'
1720
edit-mode:
1821
description: 'The mode when updating a comment, "replace" or "append".'
19-
reaction-type:
20-
description: 'Deprecated in favour of `reactions`'
22+
default: 'append'
23+
append-separator:
24+
description: 'The separator to use when appending to an existing comment. (`newline`, `space`, `none`)'
25+
default: 'newline'
2126
reactions:
22-
description: 'A comma separated list of reactions to add to the comment.'
27+
description: 'A comma or newline separated list of reactions to add to the comment.'
28+
reactions-edit-mode:
29+
description: 'The mode when updating comment reactions, "replace" or "append".'
30+
default: 'append'
2331
outputs:
2432
comment-id:
2533
description: 'The id of the created comment'

0 commit comments

Comments
 (0)