Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 16
node-version: 26
cache: npm
- run: npm ci
- uses: azure/login@v1
- run: npm ci --omit=dev
- uses: azure/login@v3
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Run Azure Functions Action
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: lts/*
node-version: 26
cache: npm
- run: npx semantic-release
env:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
cache: npm
node-version: 16
node-version: 26
- run: npm ci
- run: npm test
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.env
.envrc
node_modules
local.settings.json
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
26
16 changes: 0 additions & 16 deletions ProbotFunction/function.json

This file was deleted.

7 changes: 0 additions & 7 deletions ProbotFunction/index.js

This file was deleted.

8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,25 @@

This repository is an example of how to deploy the "Hello, World" of probot apps to [Azure Functions](https://azure.microsoft.com/en-us/services/functions).

The app uses ES modules, the [Azure Functions Node.js v4 programming model](https://learn.microsoft.com/azure/azure-functions/functions-node-upgrade-v4), and [`@probot/adapter-azure-functions`](https://github.com/probot/adapter-azure-functions) v2 (Probot 14). The function is registered in [`function.js`](function.js) and receives webhooks at `/api/ProbotFunction`.

## Local setup

Use Node.js 26 (see [`.nvmrc`](.nvmrc)). Install dependencies and start the Probot development server:

```
npm install
npm start
```

Open http://localhost:3000 and follow instructions to register a GitHub App for testing. When done, an `.env` file with your app's credentials will exist.

To run the same handler in the Azure Functions host, install [Azure Functions Core Tools](https://learn.microsoft.com/azure/azure-functions/functions-run-local) v4, add `FUNCTIONS_WORKER_RUNTIME=node` and your Probot environment variables to the `Values` of a `local.settings.json` file (ignored by Git), and run `func start`.

## Deployment through GitHub Actions

Create a Linux Function App with the Node.js 26 runtime. Node.js 26 is currently in preview on Azure.

In the Azure Console, navigate to `Function App` -> your app -> `Configuration` and add the environment variables required by Probot

- `APP_ID`
Expand Down
8 changes: 4 additions & 4 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/**
* @param {import('probot').Probot} app
* @param {import('@probot/adapter-azure-functions').Probot} app
*/
module.exports = (app) => {
app.log("Yay! The app was loaded!");
export default (app) => {
app.log.info("Yay! The app was loaded!");

app.on("issues.opened", async (context) => {
return context.octokit.issues.createComment(
return context.octokit.rest.issues.createComment(
context.issue({ body: "Hello, World!" })
);
});
Expand Down
13 changes: 13 additions & 0 deletions function.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { app } from "@azure/functions";
import {
createAzureFunction,
createProbot,
} from "@probot/adapter-azure-functions";
import probotApp from "./app.js";

// The function name keeps the webhook URL at /api/ProbotFunction
app.http("ProbotFunction", {
methods: ["POST"],
authLevel: "anonymous",
handler: createAzureFunction(probotApp, { probot: createProbot() }),
});
7 changes: 7 additions & 0 deletions host.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"version": "2.0",
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[4.*, 5.0.0)"
}
}
Loading