Skip to content

Commit 5584464

Browse files
authored
ci: Implement a PR title linter (#275)
1 parent f57f939 commit 5584464

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

.github/pull_request_template.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ Describe the use case and detail of the change. If this PR addresses an issue on
44

55
### Checklist
66

7-
Before creating a PR, run through this checklist and mark each as complete:
7+
Before creating a pull request (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)).

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

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
name: Lint PR Title
3+
on:
4+
pull_request_target:
5+
types: [opened, edited, synchronize]
6+
permissions: read-all
7+
jobs:
8+
main:
9+
name: Validate PR title
10+
runs-on: ubuntu-24.04
11+
permissions:
12+
pull-requests: write
13+
steps:
14+
- name: Check PR title
15+
id: lint_pr_title
16+
uses: amannn/action-semantic-pull-request@0723387faaf9b38adef4775cd42cfd5155ed6017 # v5.5.3
17+
env:
18+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
20+
- name: Comment on the PR if the title doesn't follow the Conventional Commits specification
21+
if: always() && (steps.lint_pr_title.outputs.error_message != null)
22+
uses: marocchino/sticky-pull-request-comment@331f8f5b4215f0445d3c07b4967662a32a2d3e31 # v2.9.0
23+
with:
24+
header: pr-title-lint-error
25+
message: |
26+
Thank you for opening this pull request! 👋🏼
27+
28+
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/).
29+
30+
Based on our linter, it looks like your proposed title needs to be adjusted. Here's the error message we received:
31+
32+
```
33+
${{ steps.lint_pr_title.outputs.error_message }}
34+
```
35+
36+
- name: Delete the previous comment once the PR title has been updated
37+
if: ${{ steps.lint_pr_title.outputs.error_message == null }}
38+
uses: marocchino/sticky-pull-request-comment@331f8f5b4215f0445d3c07b4967662a32a2d3e31 # v2.9.0
39+
with:
40+
header: pr-title-lint-error
41+
delete: true

0 commit comments

Comments
 (0)