Last active
April 10, 2023 11:27
-
-
Save VisualBean/ac55d6e120d022c811f276ca12fb2d50 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
name: Lint PR title | |
permissions: | |
pull-requests: write | |
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: | |
- if: ${{ always() }} | |
uses: amannn/action-semantic-pull-request@505e44b4f33b4c801f063838b3f053990ee46ea7 #version 4.6.0 | |
id: lint_pr_title | |
env: | |
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() && steps.lint_pr_title.outputs.error_message != null}} | |
name: Comment on PR | |
uses: marocchino/sticky-pull-request-comment@39c5b5dc7717447d0cba270cd115037d32d28443 #version 2.2 | |
with: | |
header: pr-title-lint-error | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
message: | | |
We require all PRs to follow [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/). | |
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@39c5b5dc7717447d0cba270cd115037d32d28443 #version 2.2 | |
with: | |
header: pr-title-lint-error | |
delete: true | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment