Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Modernize #79

Merged
merged 3 commits into from
Mar 12, 2024
Merged
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
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
Loading