Skip to content

Commit

Permalink
Merge pull request #49 from peter-evans/output-author
Browse files Browse the repository at this point in the history
feat: output comment author
  • Loading branch information
peter-evans authored Aug 24, 2021
2 parents 14e7863 + 56be2c2 commit 9886aa3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ jobs:
run: exit 1
- if: steps.fc1.outputs.comment-body != 'search string 1'
run: exit 1
- if: steps.fc1.outputs.comment-author != 'retepsnave'
run: exit 1

- name: Find comment by author
uses: ./
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ The action will output the comment ID of the comment matching the search criteri

#### Outputs

The `comment-id` and `comment-body` of the matching comment found will be output for use in later steps.
The `comment-id`, `comment-body` and `comment-author` 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 @@ -84,6 +84,7 @@ e.g. If `comment-id` is an empty string `steps.fc.outputs.comment-id == 0` evalu
- run: |
echo ${{ steps.fc.outputs.comment-id }}
echo ${{ steps.fc.outputs.comment-body }}
echo ${{ steps.fc.outputs.comment-author }}
```

### Accessing issues and pull requests in other repositories
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ inputs:
outputs:
comment-id:
description: 'The id of the matching comment found.'
comment-body:
description: 'The body of the matching comment found.'
comment-author:
description: 'The author of the matching comment found.'
runs:
using: 'node12'
main: 'dist/index.js'
Expand Down
2 changes: 2 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,11 @@ async function run(): Promise<void> {
if (comment) {
core.setOutput('comment-id', comment.id.toString())
core.setOutput('comment-body', comment.body)
core.setOutput('comment-author', comment.user ? comment.user.login : '')
} else {
core.setOutput('comment-id', '')
core.setOutput('comment-body', '')
core.setOutput('comment-author', '')
}
} catch (error) {
core.debug(inspect(error))
Expand Down

0 comments on commit 9886aa3

Please sign in to comment.