-
Notifications
You must be signed in to change notification settings - Fork 88
82 lines (73 loc) · 3.11 KB
/
commit-message-check.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
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
name: Commit Message Check
on:
pull_request:
env:
error_msg: |+
See the document below for help on formatting commits for the project.
https://github.com/confidential-containers/confidential-containers/blob/main/CONTRIBUTING.md#patch-format
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
commit-message-check:
runs-on: ubuntu-24.04
name: Commit Message Check
steps:
- name: Get PR Commits
id: "get-pr-commits"
uses: tim-actions/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
# Filter out revert commits
# The format of a revert commit is as follows:
#
# Revert "<original-subject-line>"
#
filter_out_pattern: '^Revert "'
- name: Commit Body Missing Check
if: ${{ ( success() || failure() ) }}
uses: tim-actions/[email protected]
with:
commits: ${{ steps.get-pr-commits.outputs.commits }}
- name: Check Subject Line Length
if: ${{ ( success() || failure() ) }}
uses: tim-actions/[email protected]
with:
commits: ${{ steps.get-pr-commits.outputs.commits }}
pattern: '^.{0,75}(\n.*)*$'
error: "Subject too long (max 75)"
post_error: ${{ env.error_msg }}
- name: Check Body Line Length
if: ${{ ( success() || failure() ) }}
uses: tim-actions/[email protected]
with:
commits: ${{ steps.get-pr-commits.outputs.commits }}
# Notes:
#
# - The subject line is not enforced here (see other check), but has
# to be specified at the start of the regex as the action is passed
# the entire commit message.
#
# - Body lines *can* be longer than the maximum if they start
# with a non-alphabetic character.
#
# This allows stack traces, log files snippets, emails, long URLs,
# etc to be specified. Some of these naturally "work" as they start
# with numeric timestamps or addresses. Emails can but quoted using
# the normal ">" character, markdown bullets ("-", "*") are also
# useful for lists of URLs, but it is always possible to override
# the check by simply space indenting the content you need to add.
#
# - A SoB comment can be any length (as it is unreasonable to penalise
# people with long names/email addresses :)
pattern: '^.+(\n([a-zA-Z].{0,149}|[^a-zA-Z\n].*|Signed-off-by:.*|))+$'
error: "Body line too long (max 72)"
post_error: ${{ env.error_msg }}
- name: Check Subsystem
if: ${{ ( success() || failure() ) }}
uses: tim-actions/[email protected]
with:
commits: ${{ steps.get-pr-commits.outputs.commits }}
pattern: '^[\s\t]*[^:\s\t]+[\s\t]*:'
error: "Failed to find subsystem in subject"
post_error: ${{ env.error_msg }}