-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* ci: add pr-title-checker action * feat: Add comment to fix PR title --------- fix: pr-title-checker permission fix: pr-title-checker permission Signed-off-by: Lin Yang <[email protected]>
- Loading branch information
1 parent
a624743
commit a6b4077
Showing
2 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"LABEL": { | ||
"name": "title needs formatting", | ||
"color": "EEEEEE" | ||
}, | ||
"CHECKS": { | ||
"prefixes": ["[Bot] docs: "], | ||
"regexp": "^(feat|fix|docs|test|ci|chore|refactor|perf)!?(\\(.*\\))?!?:.*" | ||
}, | ||
"MESSAGES": { | ||
"success": "PR title is valid", | ||
"failure": "PR title is invalid", | ||
"notice": "PR Title needs to pass regex '^(feat|fix|docs|test|ci|chore|refactor|perf)!?(\\(.*\\))?!?:.*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: "Lint PR" | ||
|
||
on: | ||
pull_request_target: | ||
types: [opened, edited, reopened, synchronize] | ||
|
||
|
||
# IMPORTANT: No checkout actions, scripts, or builds should be added to this workflow. Permissions should always be used | ||
# with extreme caution. https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target | ||
permissions: | ||
pull-requests: write | ||
contents: read | ||
|
||
# PR updates can happen in quick succession leading to this | ||
# workflow being trigger a number of times. This limits it | ||
# to one run per PR. | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
|
||
|
||
jobs: | ||
validate: | ||
name: Validate PR Title | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: PR Title Check | ||
uses: thehanimo/[email protected] | ||
id: check | ||
continue-on-error: true | ||
with: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
pass_on_octokit_error: false | ||
configuration_path: ".github/pr-title-checker-config.json" | ||
|
||
- name: Add comment to fix PR title | ||
uses: marocchino/sticky-pull-request-comment@v2 | ||
if: ${{ steps.check.outputs.success == 'false'}} | ||
with: | ||
header: 'PR Title Check' | ||
recreate: true | ||
message: | | ||
### 🚨 PR Title Needs Formatting | ||
The title of this PR needs to be formatted correctly. | ||
Please update the title to match the format `type: description AB#xxx`. Examples: | ||
* `fix: fix typo in README.md AB#123` | ||
* `chore: update dependencies AB#456` | ||
* `feat: add new feature AB#789` | ||
* `chore: fixing build pipeline` - no AB reference | ||
For more details, please refer to the [Conventional Commits Specification](https://www.conventionalcommits.org/en/v1.0.0) | ||
and the [PR Title Configuration File](.github/pr-title-checker-config.json). | ||
- name: Add comment that PR title is fixed | ||
if: ${{ steps.check.outputs.success == 'true'}} | ||
uses: marocchino/sticky-pull-request-comment@v2 | ||
with: | ||
header: 'PR Title Check' | ||
recreate: true | ||
message: | | ||
### ✅ PR Title Formatted Correctly | ||
The title of this PR has been updated to match the correct format. Thank you! |