-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (69 loc) · 3.09 KB
/
check-commit-message-pr.yaml
File metadata and controls
87 lines (69 loc) · 3.09 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
name: 🔍 Check commit message in PR
on:
pull_request:
types:
- opened
- edited
- reopened
- synchronize
jobs:
check-commit-message:
name: 🔍 Check commit message in PR
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Check for fixup commits
uses: gsactions/commit-message-checker@v2
with:
pattern: "^(?!fixup!).*$"
flags: "si"
excludeDescription: "true"
excludeTitle: "false"
checkAllCommitMessages: "true"
accessToken: ${{ secrets.GITHUB_TOKEN }}
error: |
Fixup commits are not allowed in pull requests.
Found commit message starting with "fixup!" which must be squashed before merging.
To squash fixup commits, use:
git rebase -i --autosquash origin/${{ github.event.pull_request.base.ref }}
Or manually squash the fixup commits with their target commits.
After squashing, force push the updated branch:
git push --force-with-lease origin ${{ github.event.pull_request.head.ref }}
- name: Check for Cyrillic characters
uses: gsactions/commit-message-checker@v2
with:
pattern: "^[^А-Яа-яёЁ]*$"
flags: "si"
excludeDescription: "false"
excludeTitle: "false"
checkAllCommitMessages: "true"
accessToken: ${{ secrets.GITHUB_TOKEN }}
error: |
The commit message must contain only Latin characters.
Ensure there are no Cyrillic characters in the commit title or description.
- name: Check for conventional commit message
uses: gsactions/commit-message-checker@v2
with:
pattern: '^((feat|fix|build|chore|ci|docs|refactor|perf|style|test|revert)(\([\w\/-]+\))?!?: [^\n]+(\n\n(BREAKING CHANGE: [^\n]+|.+))?)$'
flags: "si"
excludeDescription: "true"
excludeTitle: "true"
checkAllCommitMessages: "true"
accessToken: ${{ secrets.GITHUB_TOKEN }}
error: |
The commit message does not follow the conventional commit format.
A conventional commit message should be in the format:
<type>[optional scope]: <description>
[optional body]
[optional BREAKING CHANGE footer]
Example:
feat(api): add new endpoint
Or for a breaking change:
feat!: send an email to the customer
BREAKING CHANGE: `extends` key in config file is now used for extending other config files
Allowed types are: feat, fix, build, chore, ci, docs, refactor, perf, style, test, revert.
A '!' can be added after the type/scope for breaking changes (e.g., feat!:, feat(api)!:).
Alternatively, a 'BREAKING CHANGE:' footer can be used in the commit body.
Please rebase and amend the commit messages.