Skip to content

Commit 3eae4d3

Browse files
amonshizpeter-evans
authored andcommitted
feat: add the node_id to the available output (#299)
1 parent 82ff6db commit 3eae4d3

File tree

6 files changed

+44
-0
lines changed

6 files changed

+44
-0
lines changed

.github/workflows/ci.yml

+18
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ jobs:
6060
body-includes: search string 1
6161
- if: steps.fc1.outputs.comment-id != 620947762
6262
run: exit 1
63+
- if: steps.fc1.outputs.comment-node-id != 'MDEyOklzc3VlQ29tbWVudDYyMDk0Nzc2Mg=='
64+
run: exit 1
6365
- if: steps.fc1.outputs.comment-body != 'search string 1'
6466
run: exit 1
6567
- if: steps.fc1.outputs.comment-author != 'retepsnave'
@@ -73,6 +75,8 @@ jobs:
7375
comment-author: retepsnave
7476
- if: steps.fc2.outputs.comment-id != 620947762
7577
run: exit 1
78+
- if: steps.fc2.outputs.comment-node-id != 'MDEyOklzc3VlQ29tbWVudDYyMDk0Nzc2Mg=='
79+
run: exit 1
7680

7781
- name: Find comment by body-includes and author
7882
uses: ./
@@ -83,6 +87,8 @@ jobs:
8387
body-includes: search string 1
8488
- if: steps.fc3.outputs.comment-id != 620947858
8589
run: exit 1
90+
- if: steps.fc3.outputs.comment-node-id != 'MDEyOklzc3VlQ29tbWVudDYyMDk0Nzg1OA=='
91+
run: exit 1
8692

8793
- name: No matching comment found
8894
uses: ./
@@ -93,6 +99,8 @@ jobs:
9399
body-includes: this string will not be found
94100
- if: steps.fc4.outputs.comment-id != ''
95101
run: exit 1
102+
- if: steps.fc4.outputs.comment-node-id != ''
103+
run: exit 1
96104

97105
- name: Find comment by body-includes (requiring pagination)
98106
uses: ./
@@ -102,6 +110,8 @@ jobs:
102110
body-includes: search string 2
103111
- if: steps.fc5.outputs.comment-id != 703343658
104112
run: exit 1
113+
- if: steps.fc5.outputs.comment-node-id != 'MDEyOklzc3VlQ29tbWVudDcwMzM0MzY1OA=='
114+
run: exit 1
105115

106116
- name: Find comment in merged PR
107117
uses: ./
@@ -111,6 +121,8 @@ jobs:
111121
body-includes: search string 3
112122
- if: steps.fc6.outputs.comment-id != 703352283
113123
run: exit 1
124+
- if: steps.fc6.outputs.comment-node-id != 'MDEyOklzc3VlQ29tbWVudDcwMzM1MjI4Mw=='
125+
run: exit 1
114126

115127
- name: Find the last comment by body-includes and author
116128
uses: ./
@@ -122,6 +134,8 @@ jobs:
122134
direction: last
123135
- if: steps.fc7.outputs.comment-id != 771260630
124136
run: exit 1
137+
- if: steps.fc7.outputs.comment-node-id != 'MDEyOklzc3VlQ29tbWVudDc3MTI2MDYzMA=='
138+
run: exit 1
125139

126140
- name: Find comment by body-regex
127141
uses: ./
@@ -131,6 +145,8 @@ jobs:
131145
body-regex: '^.*search string 1.*$'
132146
- if: steps.fc8.outputs.comment-id != 620947762
133147
run: exit 1
148+
- if: steps.fc8.outputs.comment-node-id != 'MDEyOklzc3VlQ29tbWVudDYyMDk0Nzc2Mg=='
149+
run: exit 1
134150

135151
- name: Find nth comment by body-includes
136152
uses: ./
@@ -141,6 +157,8 @@ jobs:
141157
nth: 2
142158
- if: steps.fc9.outputs.comment-id != 703343294
143159
run: exit 1
160+
- if: steps.fc9.outputs.comment-node-id != 'MDEyOklzc3VlQ29tbWVudDcwMzM0MzI5NA=='
161+
run: exit 1
144162

145163
package:
146164
if: github.event_name == 'push' && github.ref == 'refs/heads/main'

__test__/find.unit.test.ts

+19
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ describe('findCommentPredicate tests', () => {
1616
},
1717
{
1818
id: 1,
19+
node_id: 'tornado',
1920
body: `Toto, I've a feeling we're not in Kansas anymore.`,
2021
user: {login: 'dorothy'},
2122
created_at: '2020-01-01T00:00:00Z'
@@ -37,6 +38,7 @@ describe('findCommentPredicate tests', () => {
3738
},
3839
{
3940
id: 1,
41+
node_id: 'tornado',
4042
body: `Toto, I've a feeling we're not in Kansas anymore.`,
4143
user: {login: 'dorothy'},
4244
created_at: '2020-01-01T00:00:00Z'
@@ -60,6 +62,7 @@ describe('findCommentPredicate tests', () => {
6062
},
6163
{
6264
id: 1,
65+
node_id: 'tornado',
6366
body: `Toto, I've a feeling we're not in Kansas anymore.`,
6467
user: {login: 'dorothy'},
6568
created_at: '2020-01-01T00:00:00Z'
@@ -81,6 +84,7 @@ describe('findCommentPredicate tests', () => {
8184
},
8285
{
8386
id: 1,
87+
node_id: 'tornado',
8488
body: `Toto, I've a feeling we're not in Kansas anymore.`,
8589
user: {login: 'dorothy'},
8690
created_at: '2020-01-01T00:00:00Z'
@@ -104,6 +108,7 @@ describe('findCommentPredicate tests', () => {
104108
},
105109
{
106110
id: 1,
111+
node_id: 'tornado',
107112
body: `Toto, I've a feeling we're not in Kansas anymore.`,
108113
user: {login: 'dorothy'},
109114
created_at: '2020-01-01T00:00:00Z'
@@ -125,6 +130,7 @@ describe('findCommentPredicate tests', () => {
125130
},
126131
{
127132
id: 1,
133+
node_id: 'tornado',
128134
body: `Toto, I've a feeling we're not in Kansas anymore.`,
129135
user: {login: 'dorothy'},
130136
created_at: '2020-01-01T00:00:00Z'
@@ -148,6 +154,7 @@ describe('findCommentPredicate tests', () => {
148154
},
149155
{
150156
id: 1,
157+
node_id: 'tornado',
151158
body: `Toto, I've a feeling we're not in Kansas anymore.`,
152159
user: {login: 'dorothy'},
153160
created_at: '2020-01-01T00:00:00Z'
@@ -169,6 +176,7 @@ describe('findCommentPredicate tests', () => {
169176
},
170177
{
171178
id: 1,
179+
node_id: 'tornado',
172180
body: `Toto, I've a feeling we're not in Kansas anymore.`,
173181
user: {login: 'dorothy'},
174182
created_at: '2020-01-01T00:00:00Z'
@@ -190,6 +198,7 @@ describe('findCommentPredicate tests', () => {
190198
},
191199
{
192200
id: 1,
201+
node_id: 'tornado',
193202
body: `Toto, I've a feeling we're not in Kansas anymore.`,
194203
user: {login: 'dorothy'},
195204
created_at: '2020-01-01T00:00:00Z'
@@ -213,6 +222,7 @@ describe('findCommentPredicate tests', () => {
213222
},
214223
{
215224
id: 1,
225+
node_id: 'tornado',
216226
body: `Toto, I've a feeling we're not in Kansas anymore.`,
217227
user: {login: 'dorothy'},
218228
created_at: '2020-01-01T00:00:00Z'
@@ -234,6 +244,7 @@ describe('findCommentPredicate tests', () => {
234244
},
235245
{
236246
id: 1,
247+
node_id: 'tornado',
237248
body: `Toto, I've a feeling we're not in Kansas anymore.`,
238249
user: {login: 'dorothy'},
239250
created_at: '2020-01-01T00:00:00Z'
@@ -255,6 +266,7 @@ describe('findCommentPredicate tests', () => {
255266
},
256267
{
257268
id: 1,
269+
node_id: 'tornado',
258270
body: `Toto, I've a feeling we're not in Kansas anymore.`,
259271
user: {login: 'dorothy'},
260272
created_at: '2020-01-01T00:00:00Z'
@@ -276,6 +288,7 @@ describe('findCommentPredicate tests', () => {
276288
},
277289
{
278290
id: 1,
291+
node_id: 'tornado',
279292
body: `Toto, I've a feeling we're not in Kansas anymore.`,
280293
user: {login: 'dorothy'},
281294
created_at: '2020-01-01T00:00:00Z'
@@ -299,6 +312,7 @@ describe('findCommentPredicate tests', () => {
299312
},
300313
{
301314
id: 1,
315+
node_id: 'tornado',
302316
body: `Toto, I've a feeling we're not in Kansas anymore.`,
303317
user: {login: 'dorothy'},
304318
created_at: '2020-01-01T00:00:00Z'
@@ -313,30 +327,35 @@ describe('findMatchingComment tests', () => {
313327
const testComments = [
314328
{
315329
id: 1,
330+
node_id: 'tornado',
316331
body: `Toto, I've a feeling we're not in Kansas anymore.`,
317332
user: {login: 'dorothy'},
318333
created_at: '2020-01-01T00:00:00Z'
319334
},
320335
{
321336
id: 2,
337+
node_id: 'poppies',
322338
body: `You've always had the power, my dear. You just had to learn it for yourself.`,
323339
user: {login: 'glinda'},
324340
created_at: '2020-01-01T00:00:00Z'
325341
},
326342
{
327343
id: 3,
344+
node_id: 'rubyslippers',
328345
body: `I'll get you, my pretty, and your little dog too!`,
329346
user: {login: 'wicked-witch'},
330347
created_at: '2020-01-01T00:00:00Z'
331348
},
332349
{
333350
id: 4,
351+
node_id: 'auntieem',
334352
body: `Toto, I've a feeling we're not in Kansas anymore.`,
335353
user: {login: 'dorothy'},
336354
created_at: '2020-01-01T00:00:00Z'
337355
},
338356
{
339357
id: 5,
358+
node_id: 'verybadwizard',
340359
body: `I'll get you, my pretty, and your little dog too!`,
341360
user: {login: 'wicked-witch'},
342361
created_at: '2020-01-01T00:00:00Z'

action.yml

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ inputs:
2424
outputs:
2525
comment-id:
2626
description: 'The id of the matching comment found.'
27+
comment-node-id:
28+
description: 'The GraphQL node id of the matching comment found.'
2729
comment-body:
2830
description: 'The body of the matching comment found.'
2931
comment-author:

dist/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,14 @@ function run() {
157157
const comment = yield (0, find_1.findComment)(inputs);
158158
if (comment) {
159159
core.setOutput('comment-id', comment.id.toString());
160+
core.setOutput('comment-node-id', comment.node_id);
160161
core.setOutput('comment-body', comment.body);
161162
core.setOutput('comment-author', comment.user ? comment.user.login : '');
162163
core.setOutput('comment-created-at', comment.created_at);
163164
}
164165
else {
165166
core.setOutput('comment-id', '');
167+
core.setOutput('comment-node-id', '');
166168
core.setOutput('comment-body', '');
167169
core.setOutput('comment-author', '');
168170
core.setOutput('comment-created-at', '');

src/find.ts

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export interface Inputs {
1313

1414
export interface Comment {
1515
id: number
16+
node_id: string
1617
body?: string
1718
user: {
1819
login: string

src/main.ts

+2
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ async function run(): Promise<void> {
2525

2626
if (comment) {
2727
core.setOutput('comment-id', comment.id.toString())
28+
core.setOutput('comment-node-id', comment.node_id)
2829
core.setOutput('comment-body', comment.body)
2930
core.setOutput('comment-author', comment.user ? comment.user.login : '')
3031
core.setOutput('comment-created-at', comment.created_at)
3132
} else {
3233
core.setOutput('comment-id', '')
34+
core.setOutput('comment-node-id', '')
3335
core.setOutput('comment-body', '')
3436
core.setOutput('comment-author', '')
3537
core.setOutput('comment-created-at', '')

0 commit comments

Comments
 (0)