3939 github-token : ${{ secrets.GITHUB_TOKEN }}
4040 script : |
4141 const endpoint = 'GET /repos/:owner/:repo/actions/workflows/:id/runs?&branch=:branch'
42+ const check_run_endpoint = 'GET /repos/:owner/:repo/commits/:ref/check-runs'
4243
4344 // TODO: Should use pull_request.user and pull_request.user.repos_url?
4445 // If a different person creates a commit to another forked repo,
4950 id: 'build_and_test.yml',
5051 branch: context.payload.pull_request.head.ref,
5152 }
53+ const check_run_params = {
54+ owner: context.payload.pull_request.head.repo.owner.login,
55+ repo: context.payload.pull_request.head.repo.name,
56+ ref: context.payload.pull_request.head.ref,
57+ }
5258
5359 console.log('Ref: ' + context.payload.pull_request.head.ref)
5460 console.log('SHA: ' + context.payload.pull_request.head.sha)
@@ -100,16 +106,29 @@ jobs:
100106 }
101107 })
102108 } else {
103- const runID = runs.data.workflow_runs[0].id
109+ const run_id = runs.data.workflow_runs[0].id
104110
105111 if (runs.data.workflow_runs[0].head_sha != context.payload.pull_request.head.sha) {
106112 throw new Error('There was a new unsynced commit pushed. Please retrigger the workflow.');
107113 }
108114
109- const runUrl = 'https://github.com/'
115+ // Here we get check run ID to provide Check run view instead of Actions view, see also SPARK-37879.
116+ const check_runs = await github.request(check_run_endpoint, check_run_params)
117+ const check_run_head = check_runs.data.check_runs.filter(r => r.name === "Configure jobs")[0]
118+
119+ if (check_run_head.head_sha != context.payload.pull_request.head.sha) {
120+ throw new Error('There was a new unsynced commit pushed. Please retrigger the workflow.');
121+ }
122+
123+ const check_run_url = 'https://github.com/'
124+ + context.payload.pull_request.head.repo.full_name
125+ + '/runs/'
126+ + check_run_head.id
127+
128+ const actions_url = 'https://github.com/'
110129 + context.payload.pull_request.head.repo.full_name
111130 + '/actions/runs/'
112- + runID
131+ + run_id
113132
114133 github.checks.create({
115134 owner: context.repo.owner,
@@ -119,13 +138,13 @@ jobs:
119138 status: status,
120139 output: {
121140 title: 'Test results',
122- summary: '[See test results](' + runUrl + ')',
141+ summary: '[See test results](' + check_run_url + ')',
123142 text: JSON.stringify({
124143 owner: context.payload.pull_request.head.repo.owner.login,
125144 repo: context.payload.pull_request.head.repo.name,
126- run_id: runID
145+ run_id: run_id
127146 })
128147 },
129- details_url: runUrl ,
148+ details_url: actions_url ,
130149 })
131150 }
0 commit comments