Skip to content

Commit b699538

Browse files
committed
/deploy: populate details URL
GitHubs check runs provide a neat little "view more details" link (see for example [1]) that should allow users to view the status of the check run (beyond running/queued/success/failure). Instead of just statically linking to [2], populate the URL to link to the workflow run that we're waiting for. [1] https://github.com/git-for-windows/build-extra/pull/451/checks?check_run_id=10110786774 [2] https://github.com/git-for-windows/gfw-helper-github-app Signed-off-by: Matthias Aßhauer <mha1993@live.de>
1 parent b33586f commit b699538

2 files changed

Lines changed: 46 additions & 5 deletions

File tree

GitForWindowsHelper/check-runs.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,20 @@ const queueCheckRun = async (context, token, owner, repo, ref, checkRunName, tit
4747
return id
4848
}
4949

50+
const updateCheckRun = async (context, token, owner, repo, checkRunId, parameters) => {
51+
const githubApiRequest = require('./github-api-request')
52+
53+
await githubApiRequest(
54+
context,
55+
token,
56+
'PATCH',
57+
`/repos/${owner}/${repo}/check-runs/${checkRunId}`,
58+
parameters
59+
}
60+
)
61+
}
62+
5063
module.exports = {
51-
queueCheckRun
52-
}
64+
queueCheckRun,
65+
updateCheckRun
66+
}

GitForWindowsHelper/slash-commands.js

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ module.exports = async (context, req) => {
162162
text
163163
)
164164
if (!isMSYSPackage(package_name)) {
165-
await queueCheckRun(
165+
const id = await queueCheckRun(
166166
context,
167167
await getToken(),
168168
'git-for-windows',
@@ -175,10 +175,19 @@ module.exports = async (context, req) => {
175175

176176
const answer = await triggerBuild()
177177
const answer2 = await appendToComment(`The workflow run [was started](${answer.html_url})`)
178+
await updateCheckRun(
179+
context,
180+
await getToken(),
181+
'git-for-windows',
182+
repo,
183+
id, {
184+
details_url: answer.html_url
185+
}
186+
)
178187
return `I edited the comment: ${answer2.html_url}`
179188
}
180189

181-
await queueCheckRun(
190+
const x86_64Id = await queueCheckRun(
182191
context,
183192
await getToken(),
184193
'git-for-windows',
@@ -188,7 +197,7 @@ module.exports = async (context, req) => {
188197
`Build and deploy ${package_name}`,
189198
`Deploying ${package_name}`
190199
)
191-
await queueCheckRun(
200+
const i686Id = await queueCheckRun(
192201
context,
193202
await getToken(),
194203
'git-for-windows',
@@ -204,6 +213,24 @@ module.exports = async (context, req) => {
204213
const answer2 = await appendToComment(
205214
`The [x86_64](${x86_64Answer.html_url}) and the [i686](${i686Answer.html_url}) workflow runs were started.`
206215
)
216+
await updateCheckRun(
217+
context,
218+
await getToken(),
219+
'git-for-windows',
220+
repo,
221+
x86_64Id, {
222+
details_url: x86_64Answer.html_url
223+
}
224+
)
225+
await updateCheckRun(
226+
context,
227+
await getToken(),
228+
'git-for-windows',
229+
repo,
230+
i686Id, {
231+
details_url: i686Answer.html_url
232+
}
233+
)
207234
return `I edited the comment: ${answer2.html_url}`
208235
}
209236

0 commit comments

Comments
 (0)