This is an automated email from the ASF dual-hosted git repository. potiuk pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/airflow-get-workflow-origin.git
commit 2ef0b065db6b688a2231f8a7f464df1aac254328 Author: Jarek Potiuk <[email protected]> AuthorDate: Wed Oct 28 18:54:54 2020 +0100 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 --- dist/index.js | 6 +++--- src/main.ts | 9 ++++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/dist/index.js b/dist/index.js index 7f7b836..51248f6 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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}, ` + diff --git a/src/main.ts b/src/main.ts index 87779b0..46b06ed 100644 --- a/src/main.ts +++ b/src/main.ts @@ -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` )
