Skip to content

Commit e4874c1

Browse files
authored
feat: configure devJargons github app (#36)
This Pull requests a implements the DevJargons app within the `src/lib/octokit/app` following the implementation done in #33, the intention of this app is to have an bot representation that performs some certain actions around PRs generated through the jargons.dev word editor; this actions are example... - Add appropriate labels to PRs generated through the Web UI word editor available on jargons.dev. This app is returned as an `octokit` instance that can be used to performs actions as the github app on our project repo (because we have given necessary permission). ### Screencast/Screenshot ![image](https://github.com/babblebey/jargons.dev/assets/25631971/d4c8a832-0fd7-473b-a36f-b13114053474)
1 parent 9dafed4 commit e4874c1

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

.env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
# Create a GitHub App at https://github.com/settings/apps/new
2+
GITHUB_APP_ID=
3+
# IMPORTANT: private keys must be in PKCS#8 format, see https://github.com/gr2m/universal-github-app-jwt/#about-private-key-formats
4+
GITHUB_APP_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\nMII...und==\n-----END PRIVATE KEY-----\n"
5+
26
GITHUB_OAUTH_APP_CLIENT_ID=""
37
GITHUB_OAUTH_APP_CLIENT_SECRET=""
48

src/lib/octokit/app.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
1-
import { Octokit } from "octokit";
1+
import { Octokit, App } from "octokit";
22
import { createOAuthAppAuth } from "@octokit/auth-oauth-app";
33
import { oauthAuthorizationUrl } from "@octokit/oauth-authorization-url";
44

5+
const app = new App({
6+
appId: import.meta.env.GITHUB_APP_ID,
7+
privateKey: import.meta.env.GITHUB_APP_PRIVATE_KEY,
8+
});
9+
const { data: { id } } = await app.octokit.request(`GET /repos/${import.meta.env.PROJECT_REPO}/installation`);
10+
11+
/**
12+
* DevJargons Helper App's Octokit instance
13+
*/
14+
const devJargonsOctokit = await app.getInstallationOctokit(id);
15+
516
/**
617
* OAuth App's Octokit instance
718
*/
@@ -62,6 +73,7 @@ function getUserOctokit({ token, ...options }) {
6273

6374
export default {
6475
octokit,
76+
devJargonsOctokit,
6577
oauth: {
6678
getWebFlowAuthorizationUrl,
6779
exchangeWebFlowCode,

0 commit comments

Comments
 (0)