Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

Commit

Permalink
fix octokit installation auth
Browse files Browse the repository at this point in the history
  • Loading branch information
maticzav committed Jul 22, 2022
1 parent f23ccc0 commit f1292ce
Showing 1 changed file with 12 additions and 21 deletions.
33 changes: 12 additions & 21 deletions workers/sync/src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,26 +67,17 @@ export class Worker {
/**
* Creates a new Octokit instance that is authenticated as a GitHub application.
*/
private auth(installationId: number): Promise<Octokit> {
return this.octokit.auth({
type: 'installation',
installationId,
factory: (options: any) => {
const Octo = this.octokit.constructor as typeof Octokit

return new Octo({
...options,
throttle: {
...options.throttle,
installationId,
},
auth: {
...options.auth,
installationId,
},
})
private auth(installationId: number): Octokit {
const instance = new Octokit({
authStrategy: createAppAuth,
auth: {
appId: config.ghAppId,
privateKey: config.ghPrivateKey,
installationId,
},
}) as Promise<Octokit>
})

return instance
}

/**
Expand All @@ -95,9 +86,9 @@ export class Worker {
private async tick(task: Task): Promise<boolean> {
this.logger.info(`New task "${task.kind}"!`)

const octokit = await this.auth(task.ghInstallationId)
const octokit = this.auth(task.ghInstallationId)

const endpoints = new GitHubEndpoints(octokit as Octokit)
const endpoints = new GitHubEndpoints(octokit)
const installation = { id: task.ghInstallationId }
const logger = this.logger.child({
kind: task.kind,
Expand Down

1 comment on commit f1292ce

@vercel
Copy link

@vercel vercel bot commented on f1292ce Jul 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.