Skip to content

Commit 290847c

Browse files
authored
feat: use @probot/github-action adapter (#15)
1 parent cd83eec commit 290847c

File tree

7 files changed

+176
-196
lines changed

7 files changed

+176
-196
lines changed

.github/workflows/inception.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
- opened
66

77
jobs:
8-
sayHelloWorld:
8+
issuesOpened:
99
runs-on: ubuntu-latest
1010
steps:
1111
- uses: actions/checkout@v2

.github/workflows/test.yml

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
name: Test
22
on:
3-
push:
4-
branches:
5-
- main
3+
push: {}
64
pull_request:
75
types: [opened, synchronize]
86

97
jobs:
108
test:
119
runs-on: ubuntu-latest
12-
1310
steps:
1411
- uses: actions/checkout@v2
15-
- uses: actions/setup-node@v1
12+
- uses: actions/setup-node@v2
1613
- run: npm ci
1714
- run: npm test

README.md

+17-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
> This repository is an example of how to create a GitHub Action using Probot
44
5-
[![Build Status](https://github.com/octokit/request-action/workflows/Test/badge.svg)](https://github.com/octokit/request-action/actions)
5+
[![Build Status](https://github.com/probot/example-github-action/workflows/Test/badge.svg)](https://github.com/probot/example-github-action/actions)
66

77
If you build a GitHub Action using Probot, we recommend you watch this repository as we will keep updating it implementing best practises and new APIs.
88

@@ -28,6 +28,22 @@ jobs:
2828
2929
See the action in ... action [#1](https://github.com/probot/example-github-action/issues/1)
3030
31+
Alternatively, you can pass the token with `with:`
32+
33+
```yml
34+
- uses: probot/exmaple-github-action@v1
35+
with:
36+
token: ${{ secrets.GITHUB_TOKEN }}
37+
# or
38+
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
```
40+
41+
## Configuration
42+
43+
GitHub App authentication via `APP_ID`/`PRIVATE_KEY` is not supported. Only token authentication is supported by setting `GITHUB_TOKEN`.
44+
45+
Note that the `LOG_LEVEL` environment variable is ignored. Debug logs are not logged by default in GitHub Actions, but can be enabled by creating a `ACTIONS_STEP_DEBUG` repository secret and setting it to 1.
46+
3147
## How it works
3248

3349
The Probot application function is defined in [`app.js`](app.js).

index.js

+2-41
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,4 @@
1-
const { createProbot } = require("probot");
1+
const { run } = require("@probot/adapter-github-actions");
22
const app = require("./app");
33

4-
run().catch((error) => {
5-
console.error(error);
6-
process.exit(1);
7-
});
8-
9-
async function run() {
10-
if (!process.env.GITHUB_TOKEN) {
11-
throw new Error(
12-
"[probot/example-github-action] env.GITHUB_TOKEN must be set, see https://github.com/probot/example-github-action#usage"
13-
);
14-
}
15-
16-
const envVariablesMissing = [
17-
"GITHUB_RUN_ID",
18-
"GITHUB_EVENT_NAME",
19-
"GITHUB_EVENT_PATH",
20-
].filter((name) => !process.env[name]);
21-
22-
if (envVariablesMissing.length) {
23-
throw new Error(
24-
`[probot/example-github-action] GitHub Action default environment variables missing: ${envVariablesMissing.join(
25-
", "
26-
)}. See https://docs.github.com/en/free-pro-team@latest/actions/reference/environment-variables#default-environment-variables`
27-
);
28-
}
29-
30-
const probot = createProbot({
31-
overrides: {
32-
githubToken: process.env.GITHUB_TOKEN,
33-
},
34-
});
35-
36-
await probot.load(app);
37-
38-
return probot.receive({
39-
id: process.env.GITHUB_RUN_ID,
40-
name: process.env.GITHUB_EVENT_NAME,
41-
payload: require(process.env.GITHUB_EVENT_PATH),
42-
});
43-
}
4+
run(app);

0 commit comments

Comments
 (0)