Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
feat: add env options
Browse files Browse the repository at this point in the history
  • Loading branch information
ijsKoud committed Jun 26, 2022
1 parent 64faf51 commit 69f5964
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
8 changes: 5 additions & 3 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export const REPO_NAME = "ijsKoud/ijsKoud";
export const USERNAME = "ijsKoud";
export const DEPENDENCIES_LABEL_NAME = "Dependencies";
import { cleanEnv } from "./utils";

export const REPO_NAME = cleanEnv("REPO_NAME") || "ijsKoud/ijsKoud";
export const USERNAME = cleanEnv("USERNAME") || "ijsKoud";
export const DEPENDENCIES_LABEL_NAME = cleanEnv("LABEL_DEPENDENCIES") || "Dependencies";
8 changes: 2 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ config();

import { Probot, Server } from "probot";
import { LabelSync } from "./handlers";
import { cleanEnv } from "./utils";

const getPort = () => {
let port = Number(process.env.PORT);
Expand All @@ -11,15 +12,10 @@ const getPort = () => {
return port;
};

const getPrivateKey = () => {
const key = process.env.PRIVATE_KEY ?? "";
return key.replaceAll('"', "").replaceAll("\\n", "\n");
};

const server = new Server({
Probot: Probot.defaults({
port: getPort(),
privateKey: getPrivateKey(),
privateKey: cleanEnv("PRIVATE_KEY"),
appId: process.env.APP_ID,
secret: process.env.WEBHOOK_SECRET
}),
Expand Down
4 changes: 4 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const cleanEnv = (env: string): string => {
const key = process.env[env] ?? "";
return key.replaceAll('"', "").replaceAll("\\n", "\n");
};

0 comments on commit 69f5964

Please sign in to comment.