Skip to content

Commit

Permalink
feat: initial version (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m committed Feb 9, 2021
1 parent a5a6274 commit a8ea99c
Show file tree
Hide file tree
Showing 12 changed files with 7,376 additions and 2 deletions.
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
# create PRs for out-of-range updates
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "daily"
versioning-strategy: "increase"
18 changes: 18 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Release
on:
push:
branches:
- main

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.PROBOTBOT_NPM_TOKEN }}
17 changes: 17 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Test
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize]

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- run: npm ci
- run: npm test
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
coverage
node_modules
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# 🚧 WORK IN PROGRESS [#1](https://github.com/probot/adapter-azure-functions/pull/1)

# `@probot/adapter-azure-functions`

> Adapter to run a [Probot](https://probot.github.io/) application function in [Azure Functions](https://azure.microsoft.com/services/functions/)
Expand Down
26 changes: 26 additions & 0 deletions azure-function.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module.exports = azureFunction;

/**
* @param {import('probot').Probot} probot
* @param {import('@azure/functions').Context} context
* @param {import('@azure/functions').HttpRequest} req
*/
async function azureFunction(probot, context, req) {
// this will be simpler once we ship `verifyAndParse()`
// see https://github.com/octokit/webhooks.js/issues/379
await probot.webhooks.verifyAndReceive({
id: req.headers["X-GitHub-Delivery"] || req.headers["x-github-delivery"],
name: req.headers["X-GitHub-Event"] || req.headers["x-github-event"],
signature:
req.headers["X-Hub-Signature-256"] ||
req.headers["x-hub-signature-256"] ||
req.headers["X-Hub-Signature"] ||
req.headers["x-hub-signature"],
payload: req.body,
});

context.res = {
status: "200",
body: "ok",
};
}
17 changes: 17 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const ProbotExports = require("probot");
const azureFunction = require("./azure-function");

module.exports = { ...ProbotExports, createAzureFunction };

/**
*
* @param {import('probot').ApplicationFunction} app
* @param { { probot: import('probot').Probot } } options
*/
function createAzureFunction(app, { probot }) {
// load app once outside of the function to prevent double
// event handlers in case of container reuse
probot.load(app);

return azureFunction.bind(null, probot);
}
Loading

0 comments on commit a8ea99c

Please sign in to comment.