Skip to content

Commit d769a86

Browse files
authored
Merge pull request #17 from rimrul/detail-url
/deploy: populate Details URL
2 parents 01a9475 + b699538 commit d769a86

2 files changed

Lines changed: 77 additions & 14 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: 61 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -134,17 +134,6 @@ module.exports = async (context, req) => {
134134
await thumbsUp()
135135

136136
const { queueCheckRun } = require('./check-runs')
137-
await queueCheckRun(
138-
context,
139-
await getToken(),
140-
'git-for-windows',
141-
repo,
142-
ref,
143-
'deploy',
144-
`Build and deploy ${package_name}`,
145-
`Deploying ${package_name}`
146-
)
147-
148137
const triggerWorkflowDispatch = require('./trigger-workflow-dispatch')
149138
const triggerBuild = async (architecture) =>
150139
await triggerWorkflowDispatch(
@@ -173,15 +162,75 @@ module.exports = async (context, req) => {
173162
text
174163
)
175164
if (!isMSYSPackage(package_name)) {
165+
const id = await queueCheckRun(
166+
context,
167+
await getToken(),
168+
'git-for-windows',
169+
repo,
170+
ref,
171+
'deploy',
172+
`Build and deploy ${package_name}`,
173+
`Deploying ${package_name}`
174+
)
175+
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
}
189+
190+
const x86_64Id = await queueCheckRun(
191+
context,
192+
await getToken(),
193+
'git-for-windows',
194+
repo,
195+
ref,
196+
'deploy_x86_64',
197+
`Build and deploy ${package_name}`,
198+
`Deploying ${package_name}`
199+
)
200+
const i686Id = await queueCheckRun(
201+
context,
202+
await getToken(),
203+
'git-for-windows',
204+
repo,
205+
ref,
206+
'deploy_i686',
207+
`Build and deploy ${package_name}`,
208+
`Deploying ${package_name}`
209+
)
210+
180211
const x86_64Answer = await triggerBuild('x86_64')
181212
const i686Answer = await triggerBuild('i686')
182213
const answer2 = await appendToComment(
183214
`The [x86_64](${x86_64Answer.html_url}) and the [i686](${i686Answer.html_url}) workflow runs were started.`
184215
)
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+
)
185234
return `I edited the comment: ${answer2.html_url}`
186235
}
187236

@@ -262,4 +311,4 @@ module.exports = async (context, req) => {
262311
}
263312

264313
return `Ignoring slash command ${command} in ${commentURL}`
265-
}
314+
}

0 commit comments

Comments
 (0)