-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
executable file
·59 lines (50 loc) · 1.25 KB
/
entrypoint.sh
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
53
54
55
56
57
58
59
#!/bin/bash
set -e
git config --global --add safe.directory /github/workspace
# Define the branch names
main_branch=main=$1
echo $1
echo $2
custom_pattern="${INPUT_PATTERN}"
# Get all commit messages from the feature branch that are not in the main branch
commits=($(git log --pretty="%s EON" origin/$2 ^origin/$1))
pattern=""
if [ -z "${custom_pattern}" ]; then
pattern="(feat|fix|ci|chore|docs|test|style|refactor): +#([0-9]+) -.{1,}$"
else
echo "Apply custom pattern: ${custom_pattern}"
pattern="${custom_pattern}"
fi
# Loop through the array and create other structure data
commits_struct=()
for commit in "${commits[@]}"; do
if [ $commit != "EON" ]; then
commit_msg+=" $commit"
fi
if [ $commit == "EON" ]; then
commits_struct+=("${commit_msg}")
commit_msg=""
fi
done
all_commits_ok="true"
echo "| commit | status"
for msg in "${commits_struct[@]}"; do
if [[ $msg =~ .*"Merge branch".* ]]; then
echo "$msg | skipped"
continue
fi
if [[ $msg =~ $pattern ]]; then
echo "$msg | ok"
else
echo "$msg | invalid"
all_commits_ok="false"
fi
echo "--"
done
if [ $all_commits_ok == "true" ]; then
echo "commit-checker=true" >>$GITHUB_OUTPUT
exit 0
else
echo "commit-checker=false" >>$GITHUB_OUTPUT
exit 1
fi