Skip to content

Commit

Permalink
Add "comment-created-at" as output (#88)
Browse files Browse the repository at this point in the history
* Add "comment-date" as output

* Update README.md

* comment-date -> comment-created-at
  • Loading branch information
0xCaso authored Dec 20, 2022
1 parent 79dc7b4 commit dea9995
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 15 deletions.
3 changes: 2 additions & 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-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.

Expand All @@ -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
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-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))
Expand Down

0 comments on commit dea9995

Please sign in to comment.