Skip to content

Commit 9aabaf5

Browse files
authored
chore(ci): lint on pr title
1 parent 9c58a7e commit 9aabaf5

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: 'Lint PR'
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- opened
7+
- edited
8+
9+
permissions:
10+
pull-requests: write
11+
12+
jobs:
13+
main:
14+
name: Validate PR title
15+
runs-on: ubuntu-slim
16+
permissions:
17+
pull-requests: read
18+
steps:
19+
- uses: amannn/action-semantic-pull-request@48f256284bd46cdaab1048c3721360e808335d50 # v6.1.1
20+
id: lint_pr_title
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
24+
- uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # v2.9.4
25+
# When the previous steps fails, the workflow would stop. By adding this
26+
# condition you can continue the execution with the populated error message.
27+
if: always() && (steps.lint_pr_title.outputs.error_message != null)
28+
with:
29+
header: pr-title-lint-error
30+
message: |
31+
Hey there and thank you for opening this pull request! πŸ‘‹πŸΌ
32+
33+
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.
34+
35+
Details:
36+
37+
```
38+
${{ steps.lint_pr_title.outputs.error_message }}
39+
```
40+
41+
# Delete a previous comment when the issue has been resolved
42+
- if: ${{ steps.lint_pr_title.outputs.error_message == null }}
43+
uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # v2.9.4
44+
with:
45+
header: pr-title-lint-error
46+
delete: true

0 commit comments

Comments
Β (0)