Skip to content

Commit 4b2d826

Browse files
committed
ci: add PR title check
Signed-off-by: András Jáky <ajaky@cisco.com>
1 parent 02bacd8 commit 4b2d826

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

.github/workflows/ci.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,28 @@ on:
1111
- 'v*.*.*'
1212
- 'helm/v*.*.*'
1313
pull_request:
14+
types:
15+
- opened
16+
- edited
17+
- synchronize
18+
- reopened
1419

1520
permissions:
1621
contents: write
1722
packages: write
1823
id-token: write
24+
pull-requests: write
1925

2026
concurrency:
2127
group: ${{ github.workflow }}-${{ github.ref }}
2228
cancel-in-progress: true
2329

2430
jobs:
31+
lint_pr_title:
32+
name: Lint PR Title
33+
if: github.event_name == 'pull_request'
34+
uses: ./.github/workflows/lint-pr-title.yaml
35+
2536
verify:
2637
name: Verify
2738
runs-on: ubuntu-latest
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Lint and comment PR Title
2+
3+
on:
4+
workflow_call:
5+
6+
permissions:
7+
contents: read
8+
pull-requests: write
9+
10+
jobs:
11+
validate:
12+
name: Validate
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: amannn/action-semantic-pull-request@48f256284bd46cdaab1048c3721360e808335d50 # v6.1.1
16+
id: lint_pr_title
17+
env:
18+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
19+
with:
20+
ignoreLabels: |
21+
ignore-semantic-pr
22+
subjectPattern: "^(?![A-Z]).+$"
23+
types: |
24+
build
25+
chore
26+
ci
27+
deps
28+
docs
29+
feat
30+
fix
31+
perf
32+
refactor
33+
revert
34+
style
35+
test
36+
release
37+
scopes: |
38+
server
39+
schema
40+
proto
41+
helm
42+
ci
43+
requireScope: true
44+
45+
- uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # v2.9.4
46+
if: always() && (steps.lint_pr_title.outputs.error_message != null)
47+
with:
48+
header: pr-title-lint-error
49+
message: "Hey there and thank you for opening this pull request! 👋🏼\n\nWe require pull request titles to follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/),\nand it looks like your proposed title needs to be adjusted.\n\nThe scope (component) must be one of: `server`, `schema`, `proto`, `helm`, or `ci` to indicate which component is safe to backport.\nNote: `schema` changes should not be made retroactively.\n\nDetails:\n\n```\n${{ steps.lint_pr_title.outputs.error_message }}\n```\n\nExamples:\n\n```\n- fix(server): resolve validation issue\n- feat(schema): add new module\n- deps(server): update dependencies\n- feat(proto): add new field to record proto\n- fix(helm): correct resource limits\n- ci: update workflow configuration\n```\n"
50+
51+
- if: "${{ steps.lint_pr_title.outputs.error_message == null }}"
52+
uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # v2.9.4
53+
with:
54+
header: pr-title-lint-error
55+
delete: true

0 commit comments

Comments
 (0)