diff --git a/action.yml b/action.yml index 1983d87..ef2e7b8 100644 --- a/action.yml +++ b/action.yml @@ -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) diff --git a/index.js b/index.js index 6a01ced..12b49fe 100644 --- a/index.js +++ b/index.js @@ -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, @@ -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 : '')