Skip to content

Commit 386f705

Browse files
committed
ci: update pr title lint workflow
1 parent 17ae37f commit 386f705

1 file changed

Lines changed: 35 additions & 4 deletions

File tree

.github/workflows/lint-pr.yaml

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,47 @@ on:
66
- opened
77
- reopened
88
- edited
9+
- synchronize
10+
11+
permissions:
12+
pull-requests: write
913

1014
jobs:
11-
main:
15+
validate:
1216
name: Validate PR title
1317
runs-on: ubuntu-slim
14-
permissions:
15-
pull-requests: read
18+
1619
steps:
17-
- uses: amannn/action-semantic-pull-request@2c9480cf285c2ac02b52e26013f7d627b14a4f95 # v6
20+
- name: Check PR title
21+
id: lint_pr_title
22+
uses: amannn/action-semantic-pull-request@2c9480cf285c2ac02b52e26013f7d627b14a4f95 # v6
1823
env:
1924
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2025
with:
2126
requireScope: false
27+
28+
- name: Post error comment
29+
uses: marocchino/sticky-pull-request-comment@3d7b8546315c63df45a03981d50a43ec19237f80 # v2
30+
# When the previous steps fail, the workflow would stop. By adding this
31+
# condition, execution continues with the populated error message.
32+
if: always() && (steps.lint_pr_title.outputs.error_message != null)
33+
with:
34+
header: pr-title-lint-error
35+
message: |
36+
Hey there and thank you for opening this pull request! 👋🏼
37+
38+
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.
39+
40+
Details:
41+
42+
```
43+
${{ steps.lint_pr_title.outputs.error_message }}
44+
```
45+
46+
# Delete a previous comment when the issue has been resolved
47+
- name: Delete previous comment
48+
uses: marocchino/sticky-pull-request-comment@3d7b8546315c63df45a03981d50a43ec19237f80 # v2
49+
if: ${{ steps.lint_pr_title.outputs.error_message == null }}
50+
with:
51+
header: pr-title-lint-error
52+
delete: true

0 commit comments

Comments
 (0)