Skip to content

Commit

Permalink
Merge pull request #469 from kommendorkapten/list-pr
Browse files Browse the repository at this point in the history
Avoid using search, look up pr by current commit instead
  • Loading branch information
kommendorkapten authored Nov 7, 2024
2 parents aacb507 + b79ffaf commit ddb7fe1
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions actions/signing-event/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,15 @@ runs:
script: |
const fs = require('fs')
const title = `Signing event: ${process.env.GITHUB_REF_NAME}`
const repo = `${context.repo.owner}/${context.repo.repo}`
const prs = await github.rest.search.issuesAndPullRequests({
q: `in:title+"${title}"+state:open+type:pr+repo:${repo}`
const prs = await github.rest.repos.listPullRequestsAssociatedWithCommit({
owner: context.repo.owner,
repo: context.repo.repo,
commit_sha: context.sha
})
if (prs.data.total_count > 1) {
core.setFailed("Found more than one open pull request with same title")
} else if (prs.data.total_count == 0) {
if (prs.data.length > 1) {
core.setFailed("Found more than one open pull request the current commit")
} else if (prs.data.length == 0) {
const response = await github.rest.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
Expand All @@ -94,7 +95,7 @@ runs:
pr = response.data.number
console.log(`Created pull request #${pr}`)
} else {
pr = prs.data.items[0].number
pr = prs.data[0].number
console.log(`Found existing pull request #${pr}`)
}
Expand Down

0 comments on commit ddb7fe1

Please sign in to comment.