@@ -11,63 +11,4 @@ permissions:
1111
1212jobs :
1313 validate-commit-names :
14- name : Check Commit Names
15- runs-on : ubuntu-latest
16-
17- steps :
18- # Checkout the repository
19- - name : Checkout repository
20- uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
21- with :
22- # Limit of validation to skip fetching all existing commits
23- fetch-depth : 100
24-
25- # Validate commit messages
26- - name : Validate all commit messages
27- run : |
28- echo "Validating all commit names in PR #${{ github.event.pull_request.number }}"
29-
30- # Get the base branch and the PR branch
31- BASE_BRANCH="${{ github.event.pull_request.base.ref }}"
32-
33- # Fetch the base branch with no verbosity
34- git fetch --quiet origin "$BASE_BRANCH"
35-
36- # Get all commits in the PR (not the base branch ones)
37- # --pretty=format:"%s" gets only the commit message
38- mapfile -t commits_array < <(git log origin/$BASE_BRANCH..HEAD --pretty=format:'%s')
39-
40- # Regex pattern for valid Conventional Commit
41- regex='^(docs|fix|feat|chore|refactor|test|style|build|ci): [a-z].{9,}$'
42-
43- # Variable to count errors
44- fail=0
45-
46- echo "Commit list and validation:"
47-
48- # Print and validate
49- for commitmsg in "${commits_array[@]}"; do
50- echo "$commitmsg"
51-
52- # Skip merge and [tx] commits
53- if [[ "$commitmsg" =~ ^Merge ]] || [[ "$commitmsg" =~ ^\[tx\] ]] || [[ "$commitmsg" =~ SBOM\ updated ]]; then
54- echo " 🚫 Ignored commit"
55- continue
56- fi
57-
58- # Validate Conventional Commit
59- if ! [[ "$commitmsg" =~ $regex ]]; then
60- echo " ❌ Invalid commit"
61- fail=$((fail+1))
62- else
63- echo " ✅ Valid commit"
64- fi
65- done
66-
67- # Fail the job if there are any invalid commits
68- if [[ $fail -gt 0 ]]; then
69- echo "❌ $fail commit(s) do(es) not follow the Conventional Commits convention"
70- exit 1
71- else
72- echo "✅ All commits follow the Conventional Commits convention"
73- fi
14+ uses : owncloud/reusable-workflows/.github/workflows/semantic-git-message.yml@main
0 commit comments