Skip to content

Commit 26c675d

Browse files
authored
feat: Probot v10 (#11)
BREAKING CHANGE: See changelog for Probot v10
1 parent 75e9f1f commit 26c675d

File tree

8 files changed

+751
-390
lines changed

8 files changed

+751
-390
lines changed

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "npm"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"
7+
# https://docs.github.com/en/github/administering-a-repository/keeping-your-actions-up-to-date-with-github-dependabot
8+
- package-ecosystem: "npm"
9+
directory: "/"
10+
schedule:
11+
interval: "daily"

.github/workflows/main.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
on:
2+
[push, pull_request]
3+
4+
name: Test
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Debug
11+
run: echo '${{ toJson(github) }}'
12+
- uses: actions/checkout@v2
13+
- run: npm ci
14+
- run: npm run lint
15+
- run: npm test

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,21 @@ npm i -S probot-actions-adapter
2121

2222
1. Add an `action.js` to your Probot project, like [the one shown below](#example-actionjs)
2323
1. Add an `action.yml` to your Probot project, like [the one shown below](#example-actionyml)
24-
1. _Vendor in_ your `node_modules`, as [recommended by the official Actions documentation](https://help.github.com/en/articles/creating-a-javascript-action#commit-tag-and-push-your-action-to-github)
24+
1. _Vendor in_ your `node_modules`, as [recommended by the official Actions documentation](https://docs.github.com/en/actions/creating-actions/creating-a-javascript-action#commit-tag-and-push-your-action-to-github)
2525
1. Optional, but recommended, update your project's README with an example workflow showing how to consume your action
2626

2727
### Example `action.js`
2828

2929
```javascript
3030
// Require the adapter
31-
const adapt = require('probot-actions-adapter');
31+
const runProbot = require('probot-actions-adapter');
3232

3333
// Require your Probot app's entrypoint, usually this is just index.js
34-
const probot = require('./index');
34+
const app = require('./index');
3535

3636
// Adapt the Probot app for Actions
3737
// This also acts as the main entrypoint for the Action
38-
adapt(probot);
38+
runProbot(app);
3939
```
4040

4141
### Example `action.yml`
@@ -48,11 +48,11 @@ runs:
4848
main: 'action.js'
4949
```
5050
51-
See [the documentation](https://help.github.com/en/articles/metadata-syntax-for-github-actions) for `action.yml` syntax details.
51+
See [the documentation](https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions) for `action.yml` syntax details.
5252

5353
## Authentication
5454

55-
Authentication is via [the `GITHUB_TOKEN` secret _automatically_ provided by GitHub](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token), which should be exposed as an environment variable, `GITHUB_TOKEN`. This can be achieved by including the appropriate [`env`](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#env), [`jobs.<job_id>.env`](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idenv), or [`jobs.<job_id>.steps.env`](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepsenv) value in your workflow file.
55+
Authentication is via [the `GITHUB_TOKEN` secret _automatically_ provided by GitHub](https://docs.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token), which should be exposed as an environment variable, `GITHUB_TOKEN`. This can be achieved by including the appropriate [`env`](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#env), [`jobs.<job_id>.env`](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idenv), or [`jobs.<job_id>.steps.env`](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepsenv) value in your workflow file.
5656

5757
### Example via `jobs.<job_id>.steps.env`
5858

@@ -74,7 +74,7 @@ This adapter is designed to work well with Probot apps that are essentially stat
7474

7575
A few other limitations exist:
7676

77-
1. The adapter will _only_ work for Probot apps that receive webhook events that Actions also receives: https://help.github.com/en/articles/events-that-trigger-workflows
78-
1. The adapter will _only_ work for Probot apps with a permissions set that is less than, or equivalent to the permission set attached to the `GITHUB_TOKEN`: https://help.github.com/en/articles/virtual-environments-for-github-actions#token-permissions
77+
1. The adapter will _only_ work for Probot apps that receive webhook events that Actions also receives: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
78+
1. The adapter will _only_ work for Probot apps with a permissions set that is less than, or equivalent to the permission set attached to the `GITHUB_TOKEN`: https://docs.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners#token-permissions
7979

8080
If that's you, then great! :rocket:

index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
process.env.DISABLE_STATS = 'true';
21
process.env.DISABLE_WEBHOOK_EVENT_CHECK = 'true';
32

43
const path = require('path');
54
const uuid = require('uuid');
65

76
const core = require('@actions/core');
87

9-
const { createProbot } = require('probot');
8+
const { Probot } = require('probot');
109

1110
module.exports = (...handlers) => {
1211
// Setup Probot app
1312
const githubToken = process.env.GITHUB_TOKEN;
14-
const probot = createProbot({ githubToken });
13+
const probot = new Probot({ githubToken });
1514
probot.setup(handlers);
1615

1716
// Process the event

index.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const uuid = require('uuid');
66

77
const core = require('@actions/core');
88

9-
const { createProbot } = require('probot');
9+
const { Probot } = require('probot');
1010

1111
const adapt = require('./index');
1212

@@ -23,7 +23,7 @@ describe('probot-actions-adapter', () => {
2323
receive: jest.fn(async () => true)
2424
};
2525

26-
createProbot.mockImplementation(() => {
26+
Probot.mockImplementation(() => {
2727
return probot;
2828
});
2929
});
@@ -32,7 +32,7 @@ describe('probot-actions-adapter', () => {
3232
const handler = () => {};
3333
await adapt(handler);
3434

35-
expect(createProbot).toHaveBeenCalledWith({ githubToken: 'GITHUB_TOKEN' });
35+
expect(Probot).toHaveBeenCalledWith({ githubToken: 'GITHUB_TOKEN' });
3636
expect(probot.setup).toHaveBeenCalledWith([handler]);
3737
expect(probot.receive).toHaveBeenCalledWith({ id: 'uuid-v4', name: 'push', payload: { commits: [] } });
3838
});
@@ -41,7 +41,7 @@ describe('probot-actions-adapter', () => {
4141
const handlers = [() => {}, () => {}];
4242
await adapt(...handlers);
4343

44-
expect(createProbot).toHaveBeenCalledWith({ githubToken: 'GITHUB_TOKEN' });
44+
expect(Probot).toHaveBeenCalledWith({ githubToken: 'GITHUB_TOKEN' });
4545
expect(probot.setup).toHaveBeenCalledWith(handlers);
4646
expect(probot.receive).toHaveBeenCalledWith({ id: 'uuid-v4', name: 'push', payload: { commits: [] } });
4747
});

0 commit comments

Comments
 (0)