Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "comment-created-at" as output #88

Merged
merged 3 commits into from
Dec 20, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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-date` of the matching comment found will be output for use in later steps.
0xCaso marked this conversation as resolved.
Show resolved Hide resolved
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.

Expand Down
41 changes: 27 additions & 14 deletions __test__/find.unit.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {findCommentPredicate} from '../lib/find'
import {findCommentPredicate} from '../src/find'

describe('find comment tests', () => {
test('find by bodyIncludes', async () => {
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/find.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface Comment {
user: {
login: string
} | null
created_at: string
}

export function findCommentPredicate(
Expand Down
2 changes: 2 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ async function run(): Promise<void> {
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-date', comment.created_at)
0xCaso marked this conversation as resolved.
Show resolved Hide resolved
} else {
core.setOutput('comment-id', '')
core.setOutput('comment-body', '')
core.setOutput('comment-author', '')
core.setOutput('comment-date', '')
}
} catch (error) {
core.debug(inspect(error))
Expand Down