Skip to content

Commit

Permalink
check pull request author (#18)
Browse files Browse the repository at this point in the history
* check pull request author

* Update index.js

Co-authored-by: James M. Greene <[email protected]>

Co-authored-by: James M. Greene <[email protected]>
  • Loading branch information
rachmari and JamesMGreene authored Jan 19, 2021
1 parent b097dba commit b3db845
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ inputs:
base:
description: 'The base branch name of the Pull Request'
required: false
author:
description: 'The author of the Pull Request'
required: false
outputs:
number:
description: The Pull Request's number if one was found (e.g. '345' for #345)
Expand Down
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const main = async () => {
const token = core.getInput('github-token')
const branch = core.getInput('branch')
const base = core.getInput('base')
const author = core.getInput('author')

const query = {
...context.repo,
Expand All @@ -23,7 +24,9 @@ const main = async () => {
const octokit = new GitHub(token)

const res = await octokit.pulls.list(query)
const pr = res.data.length && res.data[0]
const pr = author ?
res.data.length && res.data.filter(pr => pr.user.login === author)[0] :
res.data.length && res.data[0]

core.debug(`pr: ${JSON.stringify(pr, null, 2)}`)
core.setOutput('number', pr ? pr.number : '')
Expand Down

0 comments on commit b3db845

Please sign in to comment.