Skip to content

Commit 5c24293

Browse files
committed
[server] Fix TypeError: Cannot read property 'update' of undefined in GithubApp.onPrAddBadge
1 parent b73fab8 commit 5c24293

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

components/server/ee/src/prebuilds/github-app.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ export class GithubApp extends Probot {
247247
}
248248

249249
const newBody = body + `\n\n${button}\n\n`;
250-
const updatePrPromise: Promise<void> = (ctx.github as any).pullRequests.update({ ...ctx.repo(), number: pr.number, body: newBody });
250+
const updatePrPromise = ctx.octokit.pulls.update({ ...ctx.repo(), pull_number: pr.number, body: newBody });
251251
updatePrPromise.catch(err => log.error(err, "Error while updating PR body", { contextURL }));
252252
}
253253

@@ -265,21 +265,21 @@ export class GithubApp extends Probot {
265265

266266
if (ctx.payload.action === 'synchronize') {
267267
// someone just pushed a commit, remove the label
268-
const delLabelPromise: Promise<void> = (ctx.github as any).issues.removeLabel({ ...ctx.repo(), number: pr.number, name: label });
268+
const delLabelPromise = ctx.octokit.issues.removeLabel({ ...ctx.repo(), number: pr.number, name: label });
269269
delLabelPromise.catch(err => log.error(err, "Error while removing label from PR"));
270270
}
271271

272272
if (prebuildStartPromise) {
273273
prebuildStartPromise.then(startWsResult => {
274274
if (startWsResult.done) {
275275
if (!!startWsResult.didFinish) {
276-
const addLabelPromise: Promise<void> = (ctx.github as any).issues.addLabels({ ...ctx.repo(), number: pr.number, labels: [label] });
276+
const addLabelPromise = ctx.octokit.issues.addLabels({ ...ctx.repo(), number: pr.number, labels: [label] });
277277
addLabelPromise.catch(err => log.error(err, "Error while adding label to PR"));
278278
}
279279
} else {
280280
new PrebuildListener(this.messageBus, startWsResult.wsid, evt => {
281281
if (!HeadlessWorkspaceEventType.isRunning(evt) && HeadlessWorkspaceEventType.didFinish(evt)) {
282-
const addLabelPromise: Promise<void> = (ctx.github as any).issues.addLabels({ ...ctx.repo(), number: pr.number, labels: [label] });
282+
const addLabelPromise = ctx.octokit.issues.addLabels({ ...ctx.repo(), number: pr.number, labels: [label] });
283283
addLabelPromise.catch(err => log.error(err, "Error while adding label to PR"));
284284
}
285285
});
@@ -297,14 +297,14 @@ export class GithubApp extends Probot {
297297
const pr = ctx.payload.pull_request;
298298
const contextURL = pr.html_url;
299299
const button = `<a href="${this.env.hostUrl.withContext(contextURL)}"><img src="${this.getBadgeImageURL()}"/></a>`;
300-
const comments = await ((ctx.github as any).issues.listComments(ctx.issue()) as Promise<any>);
300+
const comments = await ctx.octokit.issues.listComments(ctx.issue());
301301
const existingComment = comments.data.find((c: any) => c.body.indexOf(button) > -1);
302302
if (existingComment) {
303303
return;
304304
}
305305

306306
const newComment = ctx.issue({ body: `\n\n${button}\n\n` });
307-
const newCommentPromise: Promise<void> = (ctx.github as any).issues.createComment(newComment);
307+
const newCommentPromise = ctx.octokit.issues.createComment(newComment);
308308
newCommentPromise.catch(err => log.error(err, "Error while adding new PR comment", { contextURL }));
309309
}
310310

0 commit comments

Comments
 (0)