Skip to content

Commit 33843f9

Browse files
authored
ci: improve pr title linter (#132)
Signed-off-by: Michael Beemer <[email protected]>
1 parent 4a82658 commit 33843f9

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

.github/workflows/pr-title-lint.yml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "Lint PR"
1+
name: 'Lint PR'
22

33
on:
44
pull_request_target:
@@ -12,6 +12,29 @@ jobs:
1212
name: Validate PR title
1313
runs-on: ubuntu-latest
1414
steps:
15-
- uses: amannn/action-semantic-pull-request@e9fabac35e210fea40ca5b14c0da95a099eff26f # v5
15+
- uses: amannn/action-semantic-pull-request@v5
16+
id: lint_pr_title
1617
env:
1718
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
20+
- uses: marocchino/sticky-pull-request-comment@v2
21+
# When the previous steps fails, the workflow would stop. By adding this
22+
# condition you can continue the execution with the populated error message.
23+
if: always() && (steps.lint_pr_title.outputs.error_message != null)
24+
with:
25+
header: pr-title-lint-error
26+
message: |
27+
Hey there and thank you for opening this pull request! 👋🏼
28+
29+
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.
30+
Details:
31+
32+
```
33+
${{ steps.lint_pr_title.outputs.error_message }}
34+
```
35+
# Delete a previous comment when the issue has been resolved
36+
- if: ${{ steps.lint_pr_title.outputs.error_message == null }}
37+
uses: marocchino/sticky-pull-request-comment@v2
38+
with:
39+
header: pr-title-lint-error
40+
delete: true

0 commit comments

Comments
 (0)