Skip to content

Commit dc7eaf0

Browse files
committed
build: validate commit and title messages
Signed-off-by: Ruben Romero Montes <[email protected]>
1 parent 5c7ad52 commit dc7eaf0

File tree

2 files changed

+42
-16
lines changed

2 files changed

+42
-16
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Validate PR
2+
3+
on:
4+
pull_request:
5+
types: [opened, edited, synchronize, reopened]
6+
issue_comment:
7+
types: [created, edited]
8+
9+
jobs:
10+
conventional-commits:
11+
name: Validate PR title
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: amannn/action-semantic-pull-request@v5
15+
env:
16+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17+
commit-message-validation:
18+
name: Validate commit messages
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
24+
- name: Set up Node.js
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: 18
28+
29+
- name: Install commitlint
30+
run: npm install -g @commitlint/{cli,config-conventional}
31+
32+
- name: Use default conventional configuration
33+
run: |
34+
echo "module.exports = { extends: ['@commitlint/config-conventional'] }" > $GITHUB_WORKSPACE/commitlint.config.js
35+
36+
- name: Validate current commit (last commit) with commitlint
37+
if: github.event_name == 'push'
38+
run: npx commitlint --from HEAD~1 --to HEAD --verbose
39+
40+
- name: Validate PR commits with commitlint
41+
if: github.event_name == 'pull_request'
42+
run: npx commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose

.github/workflows/pr.yml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,6 @@ concurrency:
1111
cancel-in-progress: true
1212

1313
jobs:
14-
task-check:
15-
name: Check task completion
16-
permissions:
17-
pull-requests: read
18-
runs-on: ubuntu-latest
19-
steps:
20-
- uses: kentaro-m/[email protected]
21-
with:
22-
repo-token: "${{ secrets.GITHUB_TOKEN }}"
23-
conventional-commits:
24-
name: Validate PR title
25-
runs-on: ubuntu-latest
26-
steps:
27-
- uses: amannn/action-semantic-pull-request@v5
28-
env:
29-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3014
test:
3115
runs-on: ubuntu-latest
3216
name: Lint and test project

0 commit comments

Comments
 (0)