Skip to content

Commit

Permalink
fix: #389, #333
Browse files Browse the repository at this point in the history
  • Loading branch information
MorrisonCole committed Sep 17, 2022
1 parent 259bc2d commit 708c389
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 13 deletions.
29 changes: 19 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
pr-lint:
runs-on: ubuntu-latest
steps:
- uses: morrisoncole/pr-lint-action@v1.6.1
- uses: morrisoncole/pr-lint-action@v1.7.0
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
title-regex: "#[eE][xX]-[0-9]+"
Expand All @@ -43,18 +43,27 @@ jobs:
## Options
| Option | Required? | Type | Default Value | Description |
| ------------------------------------------- | --------- | ------ | ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `repo-token` | yes | string | N/A | [About the `GITHUB_TOKEN` secret](https://docs.github.com/en/actions/security-guides/automatic-token-authentication#about-the-github_token-secret). |
| `title-regex` | yes | string | N/A | A JavaScript regex to test the title of each Pull Request against. |
| `on-failed-regex-fail-action` | no | bool | true | If the regex fails, sets the action status to failed. When the action exits it will be with an exit code of 1. |
| `on-failed-regex-create-review` | no | bool | true | If the regex fails, uses the GitHub review mechanism to submit a review. The review type is determined by `on-failed-regex-request-changes`. |
| `on-failed-regex-request-changes` | no | bool | true | Uses 'Request Changes' when creating a review. Otherwise, uses 'Comment'. _Note:_ if `on-failed-regex-create-review` is `false`, this won't do anything. |
| `on-failed-regex-comment` | no | string | "" | The message to post as a review comment (or the console output if `on-failed-regex-create-review` is `false`) when the regex fails. |
| `on-succeeded-regex-dismiss-review-comment` | no | string | "" | The message to post as a comment when the regex succeeds after previously failing. |
| Option | Required? | Type | Default Value | Description |
| ------------------------------------------- | --------- | ------ | ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `repo-token` | yes | string | N/A | [About the `GITHUB_TOKEN` secret](https://docs.github.com/en/actions/security-guides/automatic-token-authentication#about-the-github_token-secret). |
| `title-regex` | yes | string | ".\*" | A JavaScript regex to test the title of each Pull Request against. Allows anything by default. |
| `on-failed-regex-fail-action` | no | bool | true | If the regex fails, sets the action status to failed. When the action exits it will be with an exit code of 1. |
| `on-failed-regex-create-review` | no | bool | true | If the regex fails, uses the GitHub review mechanism to submit a review. The review type is determined by `on-failed-regex-request-changes`. |
| `on-failed-regex-request-changes` | no | bool | true | Uses 'Request Changes' when creating a review. Otherwise, uses 'Comment'. _Note:_ if `on-failed-regex-create-review` is `false`, this won't do anything. |
| `on-failed-regex-comment` | no | string | "PR title failed to match %regex%" | Comment for the bot to post on PRs that fail the regex (or the console output if `on-failed-regex-create-review` is `false`). Use %regex% to |
| reference regex. |
| `on-succeeded-regex-dismiss-review-comment` | no | string | "All good!" | The message to post as a comment when the regex succeeds after previously failing. |

## Changelog

### v1.7.0

- Fixes [#389](https://github.com/MorrisonCole/pr-lint-action/issues/389): once
the bot has commented once, it will now update that comment rather than
creating new ones.
- Fixes [#333](https://github.com/MorrisonCole/pr-lint-action/issues/333):
removed trailing period from the end of the default error message.

### v1.6.1

- Fixes [#266](https://github.com/MorrisonCole/pr-lint-action/issues/266): the
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ inputs:
"Comment for the bot to post on PRs that fail the regex. Use %regex% to
reference regex."
required: false
default: "PR title failed to match %regex%."
default: "PR title failed to match %regex%"
on-failed-regex-fail-action:
description: "Whether the action should fail when the regex doesn't match."
required: false
Expand Down
1 change: 1 addition & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ const createOrUpdateReview = (comment, pullRequest) => __awaiter(void 0, void 0,
pull_number: pullRequest.number,
review_id: review.id,
body: comment,
event: onFailedRegexRequestChanges ? "REQUEST_CHANGES" : "COMMENT",
});
}
});
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ const createOrUpdateReview = (comment, pullRequest) => __awaiter(void 0, void 0,
pull_number: pullRequest.number,
review_id: review.id,
body: comment,
event: onFailedRegexRequestChanges ? "REQUEST_CHANGES" : "COMMENT",
});
}
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pr-lint-action",
"version": "1.6.1",
"version": "1.7.0",
"description": "A GitHub Action to ensure that your PR title matches a given regex.",
"main": "lib/main.js",
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const createOrUpdateReview = async (
pull_number: pullRequest.number,
review_id: review.id,
body: comment,
event: onFailedRegexRequestChanges ? "REQUEST_CHANGES" : "COMMENT",
});
}
};
Expand Down

0 comments on commit 708c389

Please sign in to comment.