-
Notifications
You must be signed in to change notification settings - Fork 1
52 lines (45 loc) · 1.61 KB
/
commitlint.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
name: Commitlint
on:
pull_request:
branches:
- '**' # Kiểm tra commit trên tất cả các nhánh trước khi merge
push:
branches:
- '**' # Kiểm tra commit khi đẩy lên bất kỳ nhánh nào
jobs:
commitlint:
runs-on: ubuntu-22.04
steps:
# Bước 1: Checkout mã nguồn
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Lấy toàn bộ lịch sử commit
# Bước 2: Cài đặt các phụ thuộc cần thiết
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y git curl
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo DEBIAN_FRONTEND=noninteractive apt install -y nodejs
npm install
# Bước 3: In ra phiên bản của các công cụ
- name: Print versions
run: |
git --version
node --version
npm --version
npx commitlint --version
# Bước 4: Cài đặt commitlint nếu chưa cài đặt
- name: Install commitlint
run: |
npm install @commitlint/cli @commitlint/config-conventional
# Bước 5: Kiểm tra commit trên Pull Request (PR)
- name: Validate PR commits with commitlint
if: github.event_name == 'pull_request'
run: |
npx commitlint --from ${GITHUB_SHA}~1 --to ${GITHUB_SHA} --verbose
# Bước 6: Kiểm tra commit của push
- name: Validate push commit with commitlint
if: github.event_name == 'push'
run: |
npx commitlint --from HEAD~1 --to HEAD --verbose