Skip to content

Commit 1c75418

Browse files
committed
ci: implement a PR title linter
1 parent e6ce3f2 commit 1c75418

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

.github/pull_request_template.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Before creating a PR, run through this checklist and mark each as complete:
88

99
- [ ] I have read the [contributing guidelines](/CONTRIBUTING.md).
1010
- [ ] I have signed the [F5 Contributor License Agreement (CLA)](https://github.com/f5/.github/blob/main/CLA/cla-markdown.md).
11+
- [ ] The PR title follows the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/).
1112
- [ ] If applicable, I have added tests that prove my fix is effective or that my feature works.
1213
- [ ] If applicable, I have checked that any relevant tests pass after adding my changes.
1314
- [ ] I have updated any relevant documentation (e.g. [`README.md`](/README.md)).
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
name: Lint PR Title
3+
on:
4+
pull_request_target:
5+
types: [opened, edited, synchronize]
6+
jobs:
7+
main:
8+
name: Validate PR title
9+
runs-on: ubuntu-22.04
10+
permissions:
11+
pull-requests: write
12+
steps:
13+
- name: Check PR title
14+
id: lint_pr_title
15+
uses: amannn/action-semantic-pull-request@0723387faaf9b38adef4775cd42cfd5155ed6017 # v5.5.3
16+
env:
17+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
19+
- name: Comment on the PR if the title doesn't follow the Conventional Commits specification
20+
if: always() && (steps.lint_pr_title.outputs.error_message != null)
21+
uses: marocchino/sticky-pull-request-comment@331f8f5b4215f0445d3c07b4967662a32a2d3e31 # v2.9.0
22+
with:
23+
header: pr-title-lint-error
24+
message: |
25+
Thank you for opening this pull request! 👋🏼
26+
27+
In order to streamline our release process and maintain a consistent commit history, we require pull request (PR) titles to follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/).
28+
29+
Based on our linter, it looks like your proposed title needs to be adjusted. Here's the error message we received:
30+
31+
```
32+
${{ steps.lint_pr_title.outputs.error_message }}
33+
```
34+
35+
- name: Delete the previous comment once the PR title has been updated
36+
if: ${{ steps.lint_pr_title.outputs.error_message == null }}
37+
uses: marocchino/sticky-pull-request-comment@331f8f5b4215f0445d3c07b4967662a32a2d3e31 # v2.9.0
38+
with:
39+
header: pr-title-lint-error
40+
delete: true

0 commit comments

Comments
 (0)