diff --git a/.github/workflows/notify_test_workflow.yml b/.github/workflows/notify_test_workflow.yml index 17d75938a802c..04e7ab8309025 100644 --- a/.github/workflows/notify_test_workflow.yml +++ b/.github/workflows/notify_test_workflow.yml @@ -39,6 +39,7 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} script: | const endpoint = 'GET /repos/:owner/:repo/actions/workflows/:id/runs?&branch=:branch' + const check_run_endpoint = 'GET /repos/:owner/:repo/commits/:ref/check-runs' // TODO: Should use pull_request.user and pull_request.user.repos_url? // If a different person creates a commit to another forked repo, @@ -49,6 +50,11 @@ jobs: id: 'build_and_test.yml', branch: context.payload.pull_request.head.ref, } + const check_run_params = { + owner: context.payload.pull_request.head.repo.owner.login, + repo: context.payload.pull_request.head.repo.name, + ref: context.payload.pull_request.head.ref, + } console.log('Ref: ' + context.payload.pull_request.head.ref) console.log('SHA: ' + context.payload.pull_request.head.sha) @@ -100,16 +106,29 @@ jobs: } }) } else { - const runID = runs.data.workflow_runs[0].id + const run_id = runs.data.workflow_runs[0].id if (runs.data.workflow_runs[0].head_sha != context.payload.pull_request.head.sha) { throw new Error('There was a new unsynced commit pushed. Please retrigger the workflow.'); } - const runUrl = 'https://github.com/' + // Here we get check run ID to provide Check run view instead of Actions view, see also SPARK-37879. + const check_runs = await github.request(check_run_endpoint, check_run_params) + const check_run_head = check_runs.data.check_runs.filter(r => r.name === "Configure jobs")[0] + + if (check_run_head.head_sha != context.payload.pull_request.head.sha) { + throw new Error('There was a new unsynced commit pushed. Please retrigger the workflow.'); + } + + const check_run_url = 'https://github.com/' + + context.payload.pull_request.head.repo.full_name + + '/runs/' + + check_run_head.id + + const actions_url = 'https://github.com/' + context.payload.pull_request.head.repo.full_name + '/actions/runs/' - + runID + + run_id github.checks.create({ owner: context.repo.owner, @@ -119,13 +138,13 @@ jobs: status: status, output: { title: 'Test results', - summary: '[See test results](' + runUrl + ')', + summary: '[See test results](' + check_run_url + ')', text: JSON.stringify({ owner: context.payload.pull_request.head.repo.owner.login, repo: context.payload.pull_request.head.repo.name, - run_id: runID + run_id: run_id }) }, - details_url: runUrl, + details_url: actions_url, }) }