Skip to content

Commit 4230e39

Browse files
boardfishAlex Page
authored andcommitted
Add pull request review event type (#62)
* Add pull_request_review as a supported event type * Update compatible event types in README
1 parent fdb7991 commit 4230e39

File tree

5 files changed

+19
-10
lines changed

5 files changed

+19
-10
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
automate-project-columns:
3030
runs-on: ubuntu-latest
3131
steps:
32-
- uses: alex-page/github-project-automation-plus@v0.3.0
32+
- uses: alex-page/github-project-automation-plus@v0.6.0
3333
with:
3434
project: Backlog
3535
column: Triage
@@ -51,7 +51,7 @@ jobs:
5151
automate-project-columns:
5252
runs-on: ubuntu-latest
5353
steps:
54-
- uses: alex-page/github-project-automation-plus@v0.3.0
54+
- uses: alex-page/github-project-automation-plus@v0.6.0
5555
with:
5656
project: Backlog
5757
column: To do
@@ -64,8 +64,8 @@ Change these options in the workflow `.yml` file to meet your GitHub project nee
6464

6565
| Setting | Description | Values |
6666
| --- | --- | --- |
67-
| `on` | When the automation is ran | `issues` `pull_request` `issue_comment` |
68-
| `types` | The types of activity that will trigger a workflow run. | `opened`, `assigned`, `edited` |
67+
| `on` | When the automation is ran | `issues` `pull_request` `issue_comment` `pull_request_target` `pull_request_review` |
68+
| `types` | The types of activity that will trigger a workflow run. | `opened`, `assigned`, `edited`: [See GitHub docs](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request) for more |
6969
| `project` | The name of the project | `Backlog` |
7070
| `column` | The column to create or move the card to | `Triage` |
7171
| `repo-token` | The personal access token | `${{ secrets.GITHUB_TOKEN }}` |
@@ -128,6 +128,7 @@ To set up the action for local development and testing:
128128
129129
## Release History
130130
131+
- v0.6.0 - Add support for `pull_request_target` and `pull_request_review`
131132
- v0.5.1 - Fix get event data from issue_coment
132133
- v0.5.0 - Add option to `delete` card
133134
- v0.4.0 - Add `issue_comment` event

__tests__/get-action-data.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,12 @@ test('getActionData should return a formatted object from comment', t => {
205205
});
206206
});
207207

208-
test('getActionData should fail when eventName is not issues or pull_request', t => {
208+
test('getActionData should fail when eventName is not covered by action', t => {
209209
const failingMockGithubContext = Object.assign({}, mockGithubContext);
210210
const eventName = 'label';
211211
failingMockGithubContext.eventName = eventName;
212212

213213
const error = t.throws(() => getActionData(failingMockGithubContext));
214214

215-
t.is(error.message, `Only pull requests, issues or comments allowed, received:\n${eventName}`);
215+
t.is(error.message, `Only pull requests, reviews, issues, or comments allowed. Received:\n${eventName}`);
216216
});

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "github-project-automation-plus",
3-
"version": "0.5.0",
3+
"version": "0.6.0",
44
"description": "🤖 Automate GitHub Project cards with any webhook event",
55
"private": true,
66
"main": "dist/index.js",

src/get-action-data.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,18 @@
33
*
44
* @param {object} githubContext - The current issue or pull request data
55
*/
6+
const ACCEPTED_EVENT_TYPES = [
7+
'pull_request',
8+
'pull_request_target',
9+
'pull_request_review',
10+
'issues',
11+
'issue_comment'
12+
];
13+
614
const getActionData = githubContext => {
715
const {eventName, payload} = githubContext;
8-
if (eventName !== 'pull_request' && eventName !== 'pull_request_target' && eventName !== 'issues' && eventName !== 'issue_comment') {
9-
throw new Error(`Only pull requests, issues or comments allowed, received:\n${eventName}`);
16+
if (!ACCEPTED_EVENT_TYPES.includes(eventName)) {
17+
throw new Error(`Only pull requests, reviews, issues, or comments allowed. Received:\n${eventName}`);
1018
}
1119

1220
const githubData = eventName === 'issues' || eventName === 'issue_comment' ?

0 commit comments

Comments
 (0)