-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add error comment in lint-pr-title.yml #175
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
23ec676
add error comment
Krishks369 38be5e9
Merge branch 'master' into krishna/lint-pr-title
Krishks369 97d08c2
Update lint-pr-title.yml
Krishks369 ef5b919
Update lint-pr-title.yml
Krishks369 2487391
Update lint-pr-title.yml
Krishks369 4d6663c
Update lint-pr-title.yml
Krishks369 170a0aa
Update lint-pr-title.yml
Krishks369 174927a
Update lint-pr-title.yml
Krishks369 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -1,23 +1,50 @@ | ||
# This action is centrally managed in https://github.com/asyncapi/.github/ | ||
# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo | ||
|
||
|
||
|
||
name: Lint PR title | ||
|
||
on: | ||
pull_request_target: | ||
types: [opened, reopened, synchronize, edited, ready_for_review] | ||
|
||
jobs: | ||
lint-pr-title: | ||
name: Lint PR title | ||
runs-on: ubuntu-latest | ||
steps: | ||
name: Lint PR title | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Since this workflow is REQUIRED for a PR to be mergable, we have to have this 'if' statement in step level instead of job level. | ||
- if: ${{ !contains(fromJson('["asyncapi-bot", "dependabot[bot]", "dependabot-preview[bot]", "allcontributors"]'), github.actor) }} | ||
uses: amannn/[email protected] | ||
uses: Krishks369/action-semantic-pull-request@3fb9141f164e97c267a18fe560474547fd7f1fff | ||
id: lint_pr_title | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
subjectPattern: ^(?![A-Z]).+$ | ||
subjectPatternError: | | ||
The subject "{subject}" found in the pull request title "{title}" should start with a lowercase character. | ||
|
||
# Comments the error message from the above lint_pr_title action | ||
- if: always() | ||
name: Comment on PR | ||
uses: marocchino/sticky-pull-request-comment@v2 | ||
with: | ||
header: comment | ||
message: | | ||
``` | ||
Hey there 👋🏼 thanks for opening the PR but we need you to adjust the title of the pull request. | ||
We require all PRs to follow Conventional Commits specification. More details 👇🏼 | ||
|
||
|
||
${{ steps.lint_pr_title.outputs.error_message}} | ||
``` | ||
# deletes the error comment if the title is correct | ||
- if: ${{ steps.lint_pr_title.outputs.error_message == null }} | ||
name: delete the comment | ||
uses: marocchino/sticky-pull-request-comment@v2 | ||
with: | ||
header: comment | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you tested it, right? |
||
delete: true | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great. I would only suggest we add some additional message, from our side, with some emoji, not to have such a raw output as they provide in the action that we use.
So the error from
amannn/action-semantic-pull-request
is shown as code, but before it, we should have some highlight, like maybeHey there 👋🏼 thanks for opening the PR but we need you to adjust the title of the pull request. We require all PRs to follow Conventional Commits specification. More details 👇🏼
you know what I mean?