Skip to content

Commit b79ffaf

Browse files
Avoid using search, look up pr by current commit instead
Signed-off-by: Fredrik Skogman <[email protected]>
1 parent aacb507 commit b79ffaf

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

actions/signing-event/action.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,15 @@ runs:
7474
script: |
7575
const fs = require('fs')
7676
const title = `Signing event: ${process.env.GITHUB_REF_NAME}`
77-
const repo = `${context.repo.owner}/${context.repo.repo}`
78-
const prs = await github.rest.search.issuesAndPullRequests({
79-
q: `in:title+"${title}"+state:open+type:pr+repo:${repo}`
77+
const prs = await github.rest.repos.listPullRequestsAssociatedWithCommit({
78+
owner: context.repo.owner,
79+
repo: context.repo.repo,
80+
commit_sha: context.sha
8081
})
8182
82-
if (prs.data.total_count > 1) {
83-
core.setFailed("Found more than one open pull request with same title")
84-
} else if (prs.data.total_count == 0) {
83+
if (prs.data.length > 1) {
84+
core.setFailed("Found more than one open pull request the current commit")
85+
} else if (prs.data.length == 0) {
8586
const response = await github.rest.pulls.create({
8687
owner: context.repo.owner,
8788
repo: context.repo.repo,
@@ -94,7 +95,7 @@ runs:
9495
pr = response.data.number
9596
console.log(`Created pull request #${pr}`)
9697
} else {
97-
pr = prs.data.items[0].number
98+
pr = prs.data[0].number
9899
console.log(`Found existing pull request #${pr}`)
99100
}
100101

0 commit comments

Comments
 (0)