Skip to content

Commit a8ea99c

Browse files
authored
feat: initial version (#1)
1 parent a5a6274 commit a8ea99c

File tree

12 files changed

+7376
-2
lines changed

12 files changed

+7376
-2
lines changed

.github/dependabot.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: 2
2+
updates:
3+
# create PRs for out-of-range updates
4+
- package-ecosystem: "npm"
5+
directory: "/"
6+
schedule:
7+
interval: "daily"
8+
versioning-strategy: "increase"

.github/workflows/release.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Release
2+
on:
3+
push:
4+
branches:
5+
- main
6+
7+
jobs:
8+
release:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
- uses: actions/setup-node@v2
13+
with:
14+
node-version: 12
15+
- run: npx semantic-release
16+
env:
17+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
NPM_TOKEN: ${{ secrets.PROBOTBOT_NPM_TOKEN }}

.github/workflows/test.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Test
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
types: [opened, synchronize]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v2
15+
- uses: actions/setup-node@v2
16+
- run: npm ci
17+
- run: npm test

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
coverage
2+
node_modules

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# 🚧 WORK IN PROGRESS [#1](https://github.com/probot/adapter-azure-functions/pull/1)
2-
31
# `@probot/adapter-azure-functions`
42

53
> Adapter to run a [Probot](https://probot.github.io/) application function in [Azure Functions](https://azure.microsoft.com/services/functions/)

azure-function.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
module.exports = azureFunction;
2+
3+
/**
4+
* @param {import('probot').Probot} probot
5+
* @param {import('@azure/functions').Context} context
6+
* @param {import('@azure/functions').HttpRequest} req
7+
*/
8+
async function azureFunction(probot, context, req) {
9+
// this will be simpler once we ship `verifyAndParse()`
10+
// see https://github.com/octokit/webhooks.js/issues/379
11+
await probot.webhooks.verifyAndReceive({
12+
id: req.headers["X-GitHub-Delivery"] || req.headers["x-github-delivery"],
13+
name: req.headers["X-GitHub-Event"] || req.headers["x-github-event"],
14+
signature:
15+
req.headers["X-Hub-Signature-256"] ||
16+
req.headers["x-hub-signature-256"] ||
17+
req.headers["X-Hub-Signature"] ||
18+
req.headers["x-hub-signature"],
19+
payload: req.body,
20+
});
21+
22+
context.res = {
23+
status: "200",
24+
body: "ok",
25+
};
26+
}

index.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const ProbotExports = require("probot");
2+
const azureFunction = require("./azure-function");
3+
4+
module.exports = { ...ProbotExports, createAzureFunction };
5+
6+
/**
7+
*
8+
* @param {import('probot').ApplicationFunction} app
9+
* @param { { probot: import('probot').Probot } } options
10+
*/
11+
function createAzureFunction(app, { probot }) {
12+
// load app once outside of the function to prevent double
13+
// event handlers in case of container reuse
14+
probot.load(app);
15+
16+
return azureFunction.bind(null, probot);
17+
}

0 commit comments

Comments
 (0)