Skip to content

Commit c17da11

Browse files
ci: validate pull request titles
1 parent 349e8da commit c17da11

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
name: Pull Request Conventional Title
3+
4+
on:
5+
pull_request:
6+
types:
7+
- opened
8+
- edited
9+
- synchronize
10+
11+
permissions: {}
12+
13+
jobs:
14+
validate-pr-title:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
pull-requests: write
18+
steps:
19+
- uses: amannn/action-semantic-pull-request@0723387faaf9b38adef4775cd42cfd5155ed6017 # v5.5.3
20+
id: pr-title
21+
with:
22+
subjectPattern: ^(?![A-Z]).+$
23+
subjectPatternError: |
24+
The subject "{subject}" found in the pull request title "{title}"
25+
didn't match the configured pattern. Please ensure that the subject
26+
doesn't start with an uppercase character.
27+
env:
28+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29+
- uses: marocchino/sticky-pull-request-comment@331f8f5b4215f0445d3c07b4967662a32a2d3e31 # v2.9.0
30+
if: always() && steps.pr-title.outputs.error_message != null
31+
with:
32+
header: pr-title-lint-error
33+
message: |
34+
Hey there and thank you for opening this pull request! 👋🏼
35+
36+
We require pull request titles to follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/) and it looks like your proposed title needs to be adjusted.
37+
38+
:warning: Details
39+
40+
${{ steps.pr-title.outputs.error_message }}
41+
42+
- if: steps.pr-title.outputs.error_message == null
43+
uses: marocchino/sticky-pull-request-comment@331f8f5b4215f0445d3c07b4967662a32a2d3e31 # v2.9.0
44+
with:
45+
header: pr-title-lint-error
46+
delete: true

0 commit comments

Comments
 (0)