-
Notifications
You must be signed in to change notification settings - Fork 5
49 lines (44 loc) · 1.72 KB
/
commit-labelling.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
name: Commit Labeling
on:
push:
branches:
- main
- develop
- hotfix/v*
- feature/*
- fix/*
paths-ignore:
- '.gitignore'
- '**/*.md'
jobs:
commit_labeling:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Get Commit Message (Sanitized)
id: commit_message
run: |
RAW_MESSAGE=$(git log -1 --pretty=format:%s)
SAFE_MESSAGE=$(echo "$RAW_MESSAGE" | sed 's/[^a-zA-Z0-9 :_-]//g')
echo "COMMIT_MESSAGE=$SAFE_MESSAGE" >> $GITHUB_ENV
- name: Check Commit Messages for "fix", "feat", "chore", or "release"
run: |
echo "Checking commit message: $COMMIT_MESSAGE"
if [[ "$COMMIT_MESSAGE" =~ ^fix: ]]; then
echo "Commit is a FIX. Proceed with color labeling!"
echo ""
elif [[ "$COMMIT_MESSAGE" =~ ^feat: ]]; then
echo "Commit is a FEATURE. Proceed with color labeling!"
echo ""
elif [[ "$COMMIT_MESSAGE" =~ ^chore: ]]; then
echo "Commit is a CHORE. Proceed with color labeling!"
echo ""
elif [[ "$COMMIT_MESSAGE" =~ ^release: ]]; then
echo "Commit is a RELEASE. Proceed with color labeling!"
echo ""
else
echo "Commit does not match 'fix', 'feat', 'chore', or 'release'. No action."
fi
env:
COMMIT_MESSAGE: ${{ env.COMMIT_MESSAGE }}