-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
389d335
commit 65187bb
Showing
9 changed files
with
225 additions
and
84 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Octokit } from "octokit"; | ||
import { createAppAuth } from "@octokit/auth-app"; | ||
|
||
const token = process.env.GITHUB_ACCESS_TOKEN; | ||
const appId = process.env.APP_ID; | ||
const privateKey = process.env.PRIVATE_KEY; | ||
|
||
export function getOctokitInstance(): Octokit { | ||
return new Octokit({ | ||
auth: token, | ||
}); | ||
} | ||
|
||
export function getOctokitWithInstallationId(installationId: number): Octokit { | ||
return new Octokit({ | ||
authStrategy: createAppAuth, | ||
auth: { | ||
appId: appId, | ||
privateKey: privateKey, | ||
installationId: installationId, | ||
}, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,31 @@ | ||
import { Webhooks } from "@octokit/webhooks"; | ||
import { Probot } from "probot"; | ||
import { WebhookAndContext } from "../main"; | ||
|
||
export function listeningForGithubWebhookEvents(app: Probot, events: any[]) { | ||
return new Promise((resolve, reject) => { | ||
export function listeningForGithubWebhookEvents( | ||
app: Probot, | ||
events: any[], | ||
webhook: Webhooks | ||
): Promise<WebhookAndContext> { | ||
return new Promise(() => { | ||
try { | ||
app.log.info(`Listening for ${events} events`); | ||
|
||
app.on(events, async (context) => { | ||
resolve(context); | ||
let context: any; | ||
app.on(events, (res: any) => { | ||
context = res; | ||
}); | ||
webhook.on(events, (response: any) => { | ||
app.log.info(response); | ||
const data: WebhookAndContext = { | ||
context: context, | ||
webhook: response, | ||
}; | ||
Promise.resolve(data); | ||
}); | ||
} catch (error) { | ||
app.log.error(`Error occurred while listening for ${events} events`); | ||
reject(error); | ||
Promise.reject(error); | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.