Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
Remove checking head Repo when retrieving PR.
Seems that 'pull_request_review' headRepo is set wrongly in
case of PRs from forks. In 'pull_request' it points to headRepo
but in 'pull_request_review' it points to target repo

This PR should work in both cases by omitting checking the
head repo, only comparing branch and sha and adding pagination in
case the list will be long
  • Loading branch information
potiuk committed Oct 28, 2020
1 parent 15d83ef commit 2ef0b065db6b688a2231f8a7f464df1aac254328
Showing 2 changed files with 7 additions and 8 deletions.
@@ -1485,11 +1485,10 @@ function getRequiredEnv(key) {
function findPullRequest(octokit, owner, repo, headRepo, headBranch, headSha) {
return __awaiter(this, void 0, void 0, function* () {
// Finds Pull request for this workflow run
core.info(`\nFinding PR request id for: owner: ${owner}, Repo:${repo}, Head:${headRepo}:${headBranch}.\n`);
core.info(`\nFinding PR request id for: owner: ${owner}, Repo:${repo}.\n`);
const pullRequests = yield octokit.paginate(yield octokit.pulls.list({
owner,
repo,
head: `${headRepo}:${headBranch}`
repo
}));
for (const pullRequest of pullRequests) {
core.info(`\nComparing: ${pullRequest.number} sha: ${pullRequest.head.sha} with expected: ${headSha}.\n`);
@@ -1542,6 +1541,7 @@ function run() {
const eventName = getRequiredEnv('GITHUB_EVENT_NAME');
const sourceRunId = parseInt(core.getInput('sourceRunId')) || selfRunId;
const [owner, repo] = repository.split('/');
// core.info(`\nPayload: ${JSON.stringify(github.context.payload)}\n`)
core.info(`\nGetting workflow id for source run id: ${sourceRunId}, owner: ${owner}, repo: ${repo}\n`);
const sourceWorkflowId = yield getWorkflowId(octokit, sourceRunId, owner, repo);
core.info(`Repository: ${repository}, Owner: ${owner}, Repo: ${repo}, ` +
@@ -40,14 +40,11 @@ async function findPullRequest(
headSha: string
): Promise<rest.PullsListResponseItem | null> {
// Finds Pull request for this workflow run
core.info(
`\nFinding PR request id for: owner: ${owner}, Repo:${repo}, Head:${headRepo}:${headBranch}.\n`
)
core.info(`\nFinding PR request id for: owner: ${owner}, Repo:${repo}.\n`)
const pullRequests = await octokit.paginate(
await octokit.pulls.list({
owner,
repo,
head: `${headRepo}:${headBranch}`
repo
})
)
for (const pullRequest of pullRequests) {
@@ -122,6 +119,8 @@ async function run(): Promise<void> {
const sourceRunId = parseInt(core.getInput('sourceRunId')) || selfRunId
const [owner, repo] = repository.split('/')

// core.info(`\nPayload: ${JSON.stringify(github.context.payload)}\n`)

core.info(
`\nGetting workflow id for source run id: ${sourceRunId}, owner: ${owner}, repo: ${repo}\n`
)

0 comments on commit 2ef0b06

Please sign in to comment.