Skip to content

Commit c238d09

Browse files
authored
feat: use @probot/adapter-azure-functions (#6)
1 parent 2c6ae7f commit c238d09

File tree

3 files changed

+98
-113
lines changed

3 files changed

+98
-113
lines changed

ProbotFunction/index.js

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,7 @@
1-
const { createProbot } = require("probot");
1+
const {
2+
createProbot,
3+
createAzureFunction,
4+
} = require("@probot/adapter-azure-functions");
25
const app = require("../app");
36

4-
// create Probot instance using environment variables
5-
const probot = createProbot();
6-
7-
// load app once outside of the function to prevent double
8-
// event handlers in case of container reuse
9-
probot.load(app);
10-
11-
/**
12-
* @param {import('@azure/functions').Context} context
13-
* @param {import('@azure/functions').HttpRequest} req
14-
*/
15-
module.exports = async function (context, req) {
16-
// this will be simpler once we ship `verifyAndParse()`
17-
// see https://github.com/octokit/webhooks.js/issues/379
18-
await probot.webhooks.verifyAndReceive({
19-
id: req.headers["X-GitHub-Delivery"] || req.headers["x-github-delivery"],
20-
name: req.headers["X-GitHub-Event"] || req.headers["x-github-event"],
21-
signature:
22-
req.headers["X-Hub-Signature-256"] || req.headers["x-hub-signature-256"],
23-
payload: req.body,
24-
});
25-
26-
context.res = {
27-
status: "200",
28-
body: "ok",
29-
};
30-
};
7+
module.exports = createAzureFunction(app, { probot: createProbot() });

package-lock.json

Lines changed: 92 additions & 84 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"license": "ISC",
1212
"repository": "https://github.com/probot/example-azure-function",
1313
"dependencies": {
14-
"probot": "^11.0.6"
14+
"@probot/adapter-azure-functions": "^1.0.0"
1515
},
1616
"devDependencies": {
1717
"@azure/functions": "^1.2.3",

0 commit comments

Comments
 (0)