diff --git a/README.md b/README.md index 9a89572..38e84aa 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ The action will output the comment ID of the comment matching the search criteri #### Outputs -The `comment-id`, `comment-body` and `comment-author` of the matching comment found will be output for use in later steps. +The `comment-id`, `comment-body`, `comment-author` and `comment-created-at` of the matching comment found will be output for use in later steps. They will be empty strings if no matching comment was found. Note that in order to read the step outputs the action step must have an id. @@ -97,6 +97,7 @@ e.g. If `comment-id` is an empty string `steps.fc.outputs.comment-id == 0` evalu echo ${{ steps.fc.outputs.comment-id }} echo ${{ steps.fc.outputs.comment-body }} echo ${{ steps.fc.outputs.comment-author }} + echo ${{ steps.fc.outputs.comment-created-at }} ``` ### Accessing issues and pull requests in other repositories diff --git a/__test__/find.unit.test.ts b/__test__/find.unit.test.ts index 803ce94..381370a 100644 --- a/__test__/find.unit.test.ts +++ b/__test__/find.unit.test.ts @@ -1,4 +1,4 @@ -import {findCommentPredicate} from '../lib/find' +import {findCommentPredicate} from '../src/find' describe('find comment tests', () => { test('find by bodyIncludes', async () => { @@ -16,7 +16,8 @@ describe('find comment tests', () => { { id: 1, body: `Toto, I've a feeling we're not in Kansas anymore.`, - user: {login: 'dorothy'} + user: {login: 'dorothy'}, + created_at: '2020-01-01T00:00:00Z' } ) ).toEqual(true) @@ -35,7 +36,8 @@ describe('find comment tests', () => { { id: 1, body: `Toto, I've a feeling we're not in Kansas anymore.`, - user: {login: 'dorothy'} + user: {login: 'dorothy'}, + created_at: '2020-01-01T00:00:00Z' } ) ).toEqual(false) @@ -56,7 +58,8 @@ describe('find comment tests', () => { { id: 1, body: `Toto, I've a feeling we're not in Kansas anymore.`, - user: {login: 'dorothy'} + user: {login: 'dorothy'}, + created_at: '2020-01-01T00:00:00Z' } ) ).toEqual(true) @@ -75,7 +78,8 @@ describe('find comment tests', () => { { id: 1, body: `Toto, I've a feeling we're not in Kansas anymore.`, - user: {login: 'dorothy'} + user: {login: 'dorothy'}, + created_at: '2020-01-01T00:00:00Z' } ) ).toEqual(false) @@ -96,7 +100,8 @@ describe('find comment tests', () => { { id: 1, body: `Toto, I've a feeling we're not in Kansas anymore.`, - user: {login: 'dorothy'} + user: {login: 'dorothy'}, + created_at: '2020-01-01T00:00:00Z' } ) ).toEqual(true) @@ -115,7 +120,8 @@ describe('find comment tests', () => { { id: 1, body: `Toto, I've a feeling we're not in Kansas anymore.`, - user: {login: 'dorothy'} + user: {login: 'dorothy'}, + created_at: '2020-01-01T00:00:00Z' } ) ).toEqual(false) @@ -136,7 +142,8 @@ describe('find comment tests', () => { { id: 1, body: `Toto, I've a feeling we're not in Kansas anymore.`, - user: {login: 'dorothy'} + user: {login: 'dorothy'}, + created_at: '2020-01-01T00:00:00Z' } ) ).toEqual(true) @@ -155,7 +162,8 @@ describe('find comment tests', () => { { id: 1, body: `Toto, I've a feeling we're not in Kansas anymore.`, - user: {login: 'dorothy'} + user: {login: 'dorothy'}, + created_at: '2020-01-01T00:00:00Z' } ) ).toEqual(false) @@ -174,7 +182,8 @@ describe('find comment tests', () => { { id: 1, body: `Toto, I've a feeling we're not in Kansas anymore.`, - user: {login: 'dorothy'} + user: {login: 'dorothy'}, + created_at: '2020-01-01T00:00:00Z' } ) ).toEqual(false) @@ -195,7 +204,8 @@ describe('find comment tests', () => { { id: 1, body: `Toto, I've a feeling we're not in Kansas anymore.`, - user: {login: 'dorothy'} + user: {login: 'dorothy'}, + created_at: '2020-01-01T00:00:00Z' } ) ).toEqual(true) @@ -214,7 +224,8 @@ describe('find comment tests', () => { { id: 1, body: `Toto, I've a feeling we're not in Kansas anymore.`, - user: {login: 'dorothy'} + user: {login: 'dorothy'}, + created_at: '2020-01-01T00:00:00Z' } ) ).toEqual(false) @@ -233,7 +244,8 @@ describe('find comment tests', () => { { id: 1, body: `Toto, I've a feeling we're not in Kansas anymore.`, - user: {login: 'dorothy'} + user: {login: 'dorothy'}, + created_at: '2020-01-01T00:00:00Z' } ) ).toEqual(false) @@ -254,7 +266,8 @@ describe('find comment tests', () => { { id: 1, body: `Toto, I've a feeling we're not in Kansas anymore.`, - user: {login: 'dorothy'} + user: {login: 'dorothy'}, + created_at: '2020-01-01T00:00:00Z' } ) ).toEqual(true) diff --git a/src/find.ts b/src/find.ts index 62bf472..5c28771 100644 --- a/src/find.ts +++ b/src/find.ts @@ -16,6 +16,7 @@ export interface Comment { user: { login: string } | null + created_at: string } export function findCommentPredicate( diff --git a/src/main.ts b/src/main.ts index d0be045..71091e5 100644 --- a/src/main.ts +++ b/src/main.ts @@ -26,10 +26,12 @@ async function run(): Promise { core.setOutput('comment-id', comment.id.toString()) core.setOutput('comment-body', comment.body) core.setOutput('comment-author', comment.user ? comment.user.login : '') + core.setOutput('comment-created-at', comment.created_at) } else { core.setOutput('comment-id', '') core.setOutput('comment-body', '') core.setOutput('comment-author', '') + core.setOutput('comment-created-at', '') } } catch (error) { core.debug(inspect(error))