Skip to content

Commit 1451412

Browse files
committed
Roll our own
1 parent e609c25 commit 1451412

File tree

2 files changed

+47
-15
lines changed

2 files changed

+47
-15
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: 'Validate PR Title'
2+
description: 'Validates that PR titles follow conventional commit format with custom types'
3+
inputs:
4+
title:
5+
description: 'PR title to validate'
6+
required: true
7+
outputs:
8+
valid:
9+
description: 'Whether the title is valid'
10+
value: ${{ steps.validate.outputs.valid }}
11+
runs:
12+
using: 'composite'
13+
steps:
14+
- name: Validate PR title
15+
id: validate
16+
shell: bash
17+
run: |
18+
title="${{ inputs.title }}"
19+
20+
# Define allowed types
21+
allowed_types="feat|fix|docs|style|refactor|perf|test|build|ci|chore|deps"
22+
23+
# Check if title matches conventional commit format
24+
if echo "$title" | grep -qE "^($allowed_types)(\(.+\))?!?: .+"; then
25+
echo "valid=true" >> $GITHUB_OUTPUT
26+
echo "✅ PR title is valid: $title"
27+
else
28+
echo "valid=false" >> $GITHUB_OUTPUT
29+
echo "❌ PR title is invalid: $title"
30+
echo ""
31+
echo "Expected format: <type>[optional scope]: <description>"
32+
echo ""
33+
echo "Allowed types: $allowed_types"
34+
echo ""
35+
echo "Examples:"
36+
echo " feat: add new feature"
37+
echo " fix: resolve bug"
38+
echo " deps: update dependencies"
39+
echo " chore: update CI configuration"
40+
exit 1
41+
fi

.github/workflows/lint-pr.yml

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,10 @@ jobs:
1212
name: Validate PR title
1313
runs-on: ubuntu-latest
1414
steps:
15-
- uses: amannn/action-semantic-pull-request@v6
16-
env:
17-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15+
- name: Checkout
16+
uses: actions/checkout@v5
17+
18+
- name: Validate PR title
19+
uses: ./.github/actions/validate-pr-title
1820
with:
19-
types: |
20-
feat
21-
fix
22-
docs
23-
style
24-
refactor
25-
perf
26-
test
27-
build
28-
ci
29-
chore
30-
deps
21+
title: ${{ github.event.pull_request.title }}

0 commit comments

Comments
 (0)