-
Notifications
You must be signed in to change notification settings - Fork 19
38 lines (34 loc) · 1.55 KB
/
ci-commit-titles.yaml
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
name: "[ci]: Commit titles"
on:
pull_request:
jobs:
check:
runs-on: ubuntu-latest
steps:
- name: titles
run: |
curl ${{ github.event.pull_request.commits_url }} > commits.txt
cat commits.txt | jq '.[].commit.message' | sed -E 's/\\n.*/"/g' | jq -r > titles.txt
grep -vE '^(build|chore|ci|docs|feat|fix|refactor|revert|test)(\(\S+\))?!?: [a-z]+' titles.txt > bad_titles.txt || true
if [ "$(cat bad_titles.txt | wc -c)" -gt 0 ]; then
echo "Please check your commit titles, they should correspond to https://www.conventionalcommits.org/en/v1.0.0/";
echo -e "\nThe titles below should be fixed:";
cat bad_titles.txt
false
fi
- name: "feat|fix"
run: |
grep -E '^(feat|fix)(\(\S+\))?!?: [a-z]+' titles.txt > feat-fix.txt || (
echo "You have to provide at least one 'feat'|'fix' commit to publish new versions of changed packages.";
echo "If you don't want to release new version then just ignore the check.";
false
)
- name: "issue|ticket"
run: |
grep -P '\[(#\d+)|(YTFRONT-\d+)\]$' feat-fix.txt || (
echo "At least one of your commits should be linked with an issue or a ticket.";
echo "Such commit should contain '[#xxx]' or '[YTFRONT-xxx]' at the end of title".;
echo "If you don't want to link your PR with any issue/ticket then just ignore the check";
cat feat-fix.txt;
false
)