Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ inputs:
description: 'The direction of the sort. Can be either `asc` or `desc`.'
default: 'desc'
required: false
title:
description: 'Title of the Pull Request to search for.'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description: 'Title of the Pull Request to search for.'
description: 'The title of the Pull Request'

required: false

outputs:
number:
Expand Down
11 changes: 8 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const main = async () => {
const state = core.getInput('state')
const sort = core.getInput('sort')
const direction = core.getInput('direction')
const title = core.getInput('title')
const repoString = core.getInput('repo')

let repoObject
Expand Down Expand Up @@ -44,9 +45,13 @@ const main = async () => {
const octokit = github.getOctokit(token)

const res = await octokit.rest.pulls.list(query)
const pr = author
? res.data.length && res.data.filter(pr => pr.user.login === author)[0]
: res.data.length && res.data[0]
const pr =
res.data.length &&
res.data.filter(
pr =>
(!author || pr.user.login === author) &&
(!title || pr.title.match(new RegExp(title)))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you need this to be a regular expression? could it be a substring? or do you want to match on the exact title?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regex covers more use cases; pattern matching, partial matching or exact matches should be supported (I haven't tried this). Plain strings can still be used, with the cavat that special characters will have to be escaped. (This is how I'm using it).

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha, shall we simplify this PR then by only supporting exact matches for now?

)[0]

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