Skip to content

Commit

Permalink
feat!: Modernize
Browse files Browse the repository at this point in the history
This ports to ESM, vitest and Probot 13
  • Loading branch information
AaronDewes committed Mar 9, 2024
1 parent 5545290 commit 21a68e9
Show file tree
Hide file tree
Showing 9 changed files with 2,194 additions and 4,881 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions/setup-node@v3
with:
cache: npm
node-version: 16
node-version: 18
- run: npm ci
- run: npm test
createComment:
Expand All @@ -25,7 +25,7 @@ jobs:
- uses: actions/setup-node@v3
with:
cache: npm
node-version: 16
node-version: 18
- run: npm ci
- run: node test/fixtures/app.js
env:
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Create your Probot Application as always

```js
// app.js
module.exports = (app) => {
export default (app) => {
app.on("issues.opened", async (context) => {
const params = context.issue({ body: "Hello World!" });
await context.octokit.issues.createComment(params);
Expand All @@ -22,8 +22,8 @@ Then in the entrypoint of your GitHub Action, require `@probot/adapter-github-ac

```js
// index.js
const { run } = require('@probot/adapter-github-actions')
const app = require("./app");
import { run } from "@probot/adapter-github-actions";
import app from "./app.js";

run(app).catch((error) => {
console.error(error);
Expand All @@ -37,7 +37,7 @@ Then use `index.js` as your entrypoint in the `action.yml` file
name: "Probot app name"
description: "Probot app description."
runs:
using: "node12"
using: "node20"
main: "index.js"
```
Expand Down
16 changes: 8 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const ProbotExports = require("probot");
const pino = require("pino");
export * from "probot";
import { createProbot } from "probot";
import pino from "pino";
import { readFileSync } from "node:fs";

const { transport } = require("./pino-transport-github-actions");
import { transport } from "./pino-transport-github-actions.js";

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

async function run(app) {
export async function run(app) {
const log = pino({}, transport);

const githubToken =
Expand Down Expand Up @@ -35,7 +35,7 @@ async function run(app) {
return;
}

const probot = ProbotExports.createProbot({
const probot = createProbot({
overrides: {
githubToken,
log,
Expand All @@ -48,7 +48,7 @@ async function run(app) {
.receive({
id: process.env.GITHUB_RUN_ID,
name: process.env.GITHUB_EVENT_NAME,
payload: require(process.env.GITHUB_EVENT_PATH),
payload: JSON.parse(readFileSync(process.env.GITHUB_EVENT_PATH)),
})
.catch((error) => {
probot.log.error(error);
Expand Down
Loading

0 comments on commit 21a68e9

Please sign in to comment.