-
-
Notifications
You must be signed in to change notification settings - Fork 3
47 lines (42 loc) · 2.44 KB
/
lint-pr-title.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# 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:
# 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[bot]"]'), github.actor) }}
uses: amannn/action-semantic-pull-request@0723387faaf9b38adef4775cd42cfd5155ed6017 #version 5.5.3 https://github.com/amannn/action-semantic-pull-request/releases/tag/v5.5.3
id: lint_pr_title
env:
GITHUB_TOKEN: ${{ secrets.GH_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 && !contains(fromJson('["asyncapi-bot", "dependabot[bot]", "dependabot-preview[bot]", "allcontributors[bot]"]'), github.actor)}}
name: Comment on PR
uses: marocchino/sticky-pull-request-comment@331f8f5b4215f0445d3c07b4967662a32a2d3e31 #use 2.9.0 https://github.com/marocchino/sticky-pull-request-comment/releases/tag/v2.9.0
with:
header: pr-title-lint-error
GITHUB_TOKEN: ${{ secrets.GH_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@331f8f5b4215f0445d3c07b4967662a32a2d3e31 #use 2.9.0 https://github.com/marocchino/sticky-pull-request-comment/releases/tag/v2.9.0
with:
header: pr-title-lint-error
delete: true
GITHUB_TOKEN: ${{ secrets.GH_TOKEN}}