Skip to content

Commit

Permalink
fix: stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
mattzcarey committed Nov 10, 2023
1 parent b76fab4 commit 989e9f0
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 1,416 deletions.
14 changes: 13 additions & 1 deletion services/core/functions/webhook/bot.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
/* eslint-disable */
import { Context, Probot } from "probot";

import { loadChat } from "./chat/loadChat";

export const bot = (app: Probot): void => {
export const app = (app: Probot): void => {
app.on(
["pull_request.opened", "pull_request.synchronize"],
async (context: Context) => {
const repo = context.repo();

console.log("Received event:", context.name, repo);

const chat = await loadChat(context);

try {
Expand All @@ -19,9 +22,18 @@ export const bot = (app: Probot): void => {
issue_number: context.pullRequest().pull_number,
body: review,
});

console.log("Commented on PR:", repo);
} catch (e) {
console.error(e);
}

console.info(
"successfully reviewed",
context.payload.pull_request.html_url
);

return "success";
}
);
};
6 changes: 3 additions & 3 deletions services/core/functions/webhook/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ export class WebhookLambda extends NodejsFunction {
super(scope, id, {
...commonLambdaProps,
functionName: buildResourceName(id),
entry: join(__dirname, "index.ts"),
entry: join(__dirname, "handler.cjs"),
environment: {
APP_ID: getEnvVariable("APP_ID"),
PRIVATE_KEY: getEnvVariable("PRIVATE_KEY"),
WEBHOOK_SECRET: getEnvVariable("WEBHOOK_SECRET"),
NODE_ENV: getEnvVariableOrDefault("NODE_ENV", "production"),
LOG_LEVEL: getEnvVariableOrDefault("LOG_LEVEL", "info"),
NODE_ENV: getEnvVariableOrDefault("NODE_ENV", "development"),
LOG_LEVEL: getEnvVariableOrDefault("LOG_LEVEL", "debug"),
},
});
}
Expand Down
11 changes: 11 additions & 0 deletions services/core/functions/webhook/handler.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
global.crypto = require("crypto");
const {
createLambdaFunction,
createProbot,
} = require("@probot/adapter-aws-lambda-serverless");

const appFn = require("./bot").app;

module.exports.main = createLambdaFunction(appFn, {
probot: createProbot(),
});
20 changes: 0 additions & 20 deletions services/core/functions/webhook/index.ts

This file was deleted.

Loading

0 comments on commit 989e9f0

Please sign in to comment.