Skip to content

Commit dea9995

Browse files
authored
Add "comment-created-at" as output (#88)
* Add "comment-date" as output * Update README.md * comment-date -> comment-created-at
1 parent 79dc7b4 commit dea9995

4 files changed

Lines changed: 32 additions & 15 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ The action will output the comment ID of the comment matching the search criteri
7979

8080
#### Outputs
8181

82-
The `comment-id`, `comment-body` and `comment-author` of the matching comment found will be output for use in later steps.
82+
The `comment-id`, `comment-body`, `comment-author` and `comment-created-at` of the matching comment found will be output for use in later steps.
8383
They will be empty strings if no matching comment was found.
8484
Note that in order to read the step outputs the action step must have an id.
8585

@@ -97,6 +97,7 @@ e.g. If `comment-id` is an empty string `steps.fc.outputs.comment-id == 0` evalu
9797
echo ${{ steps.fc.outputs.comment-id }}
9898
echo ${{ steps.fc.outputs.comment-body }}
9999
echo ${{ steps.fc.outputs.comment-author }}
100+
echo ${{ steps.fc.outputs.comment-created-at }}
100101
```
101102

102103
### Accessing issues and pull requests in other repositories

__test__/find.unit.test.ts

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {findCommentPredicate} from '../lib/find'
1+
import {findCommentPredicate} from '../src/find'
22

33
describe('find comment tests', () => {
44
test('find by bodyIncludes', async () => {
@@ -16,7 +16,8 @@ describe('find comment tests', () => {
1616
{
1717
id: 1,
1818
body: `Toto, I've a feeling we're not in Kansas anymore.`,
19-
user: {login: 'dorothy'}
19+
user: {login: 'dorothy'},
20+
created_at: '2020-01-01T00:00:00Z'
2021
}
2122
)
2223
).toEqual(true)
@@ -35,7 +36,8 @@ describe('find comment tests', () => {
3536
{
3637
id: 1,
3738
body: `Toto, I've a feeling we're not in Kansas anymore.`,
38-
user: {login: 'dorothy'}
39+
user: {login: 'dorothy'},
40+
created_at: '2020-01-01T00:00:00Z'
3941
}
4042
)
4143
).toEqual(false)
@@ -56,7 +58,8 @@ describe('find comment tests', () => {
5658
{
5759
id: 1,
5860
body: `Toto, I've a feeling we're not in Kansas anymore.`,
59-
user: {login: 'dorothy'}
61+
user: {login: 'dorothy'},
62+
created_at: '2020-01-01T00:00:00Z'
6063
}
6164
)
6265
).toEqual(true)
@@ -75,7 +78,8 @@ describe('find comment tests', () => {
7578
{
7679
id: 1,
7780
body: `Toto, I've a feeling we're not in Kansas anymore.`,
78-
user: {login: 'dorothy'}
81+
user: {login: 'dorothy'},
82+
created_at: '2020-01-01T00:00:00Z'
7983
}
8084
)
8185
).toEqual(false)
@@ -96,7 +100,8 @@ describe('find comment tests', () => {
96100
{
97101
id: 1,
98102
body: `Toto, I've a feeling we're not in Kansas anymore.`,
99-
user: {login: 'dorothy'}
103+
user: {login: 'dorothy'},
104+
created_at: '2020-01-01T00:00:00Z'
100105
}
101106
)
102107
).toEqual(true)
@@ -115,7 +120,8 @@ describe('find comment tests', () => {
115120
{
116121
id: 1,
117122
body: `Toto, I've a feeling we're not in Kansas anymore.`,
118-
user: {login: 'dorothy'}
123+
user: {login: 'dorothy'},
124+
created_at: '2020-01-01T00:00:00Z'
119125
}
120126
)
121127
).toEqual(false)
@@ -136,7 +142,8 @@ describe('find comment tests', () => {
136142
{
137143
id: 1,
138144
body: `Toto, I've a feeling we're not in Kansas anymore.`,
139-
user: {login: 'dorothy'}
145+
user: {login: 'dorothy'},
146+
created_at: '2020-01-01T00:00:00Z'
140147
}
141148
)
142149
).toEqual(true)
@@ -155,7 +162,8 @@ describe('find comment tests', () => {
155162
{
156163
id: 1,
157164
body: `Toto, I've a feeling we're not in Kansas anymore.`,
158-
user: {login: 'dorothy'}
165+
user: {login: 'dorothy'},
166+
created_at: '2020-01-01T00:00:00Z'
159167
}
160168
)
161169
).toEqual(false)
@@ -174,7 +182,8 @@ describe('find comment tests', () => {
174182
{
175183
id: 1,
176184
body: `Toto, I've a feeling we're not in Kansas anymore.`,
177-
user: {login: 'dorothy'}
185+
user: {login: 'dorothy'},
186+
created_at: '2020-01-01T00:00:00Z'
178187
}
179188
)
180189
).toEqual(false)
@@ -195,7 +204,8 @@ describe('find comment tests', () => {
195204
{
196205
id: 1,
197206
body: `Toto, I've a feeling we're not in Kansas anymore.`,
198-
user: {login: 'dorothy'}
207+
user: {login: 'dorothy'},
208+
created_at: '2020-01-01T00:00:00Z'
199209
}
200210
)
201211
).toEqual(true)
@@ -214,7 +224,8 @@ describe('find comment tests', () => {
214224
{
215225
id: 1,
216226
body: `Toto, I've a feeling we're not in Kansas anymore.`,
217-
user: {login: 'dorothy'}
227+
user: {login: 'dorothy'},
228+
created_at: '2020-01-01T00:00:00Z'
218229
}
219230
)
220231
).toEqual(false)
@@ -233,7 +244,8 @@ describe('find comment tests', () => {
233244
{
234245
id: 1,
235246
body: `Toto, I've a feeling we're not in Kansas anymore.`,
236-
user: {login: 'dorothy'}
247+
user: {login: 'dorothy'},
248+
created_at: '2020-01-01T00:00:00Z'
237249
}
238250
)
239251
).toEqual(false)
@@ -254,7 +266,8 @@ describe('find comment tests', () => {
254266
{
255267
id: 1,
256268
body: `Toto, I've a feeling we're not in Kansas anymore.`,
257-
user: {login: 'dorothy'}
269+
user: {login: 'dorothy'},
270+
created_at: '2020-01-01T00:00:00Z'
258271
}
259272
)
260273
).toEqual(true)

src/find.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export interface Comment {
1616
user: {
1717
login: string
1818
} | null
19+
created_at: string
1920
}
2021

2122
export function findCommentPredicate(

src/main.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@ async function run(): Promise<void> {
2626
core.setOutput('comment-id', comment.id.toString())
2727
core.setOutput('comment-body', comment.body)
2828
core.setOutput('comment-author', comment.user ? comment.user.login : '')
29+
core.setOutput('comment-created-at', comment.created_at)
2930
} else {
3031
core.setOutput('comment-id', '')
3132
core.setOutput('comment-body', '')
3233
core.setOutput('comment-author', '')
34+
core.setOutput('comment-created-at', '')
3335
}
3436
} catch (error) {
3537
core.debug(inspect(error))

0 commit comments

Comments
 (0)