-
Notifications
You must be signed in to change notification settings - Fork 57
109 lines (98 loc) · 4.08 KB
/
pr_title.yml
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
name: PR title
on:
pull_request:
types: [opened, synchronize, reopened, edited]
jobs:
title_cc_validation:
name: Conventional commits validation
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Check PR title
env:
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
# If this step fails, please expand this step for more information.
#
# You will need to revise this pull request's title to
# match the "summary" (first) line of a Conventional Commit message.
# This enables us to automatically generate a meaningful changelog.
#
# The summary line (and thus the PR title) must have this exact format
# (including punctuation):
#
# type(scope): description
#
# `type` describes the nature of changes you are making. This project
# requires the type to be one of these exact names:
#
# * fix
# * feat (will cause a minor version bump)
# * chore (will be omitted from changelog)
# * update
# * doc
#
# `scope` describes where the change is made. This project allows
# the scope to be omitted, but if it is present, it must be one of
# these exact names:
#
# * sdk (The primary C2PA Rust SDK)
# * export_schema
# * make_test_images
#
# If `scope` is omitted, the parenthesis must also be omitted.
#
# `description` is a short human-readable summary of the changes being made.
#
# This project enforces a few rules over and above the Conventional
# Commits definition of `description`:
#
# * The `description` must be non-empty.
# * The `description` must start with a capital letter or number.
# (Do not start `description` with a lower-case word.)
# * The `description` must not end with a period.
#
# This project does not currently enforce the following items, but
# we ask that you observe the following preferences in `description`:
#
# * The entire description should be written and capitalized as
# an English-language sentence, except (as noted earlier) that
# the trailing period must be omitted.
# * Any acronyms such as JSON or YAML should be capitalized as per
# common usage in English-language sentences.
#
# After you edit the PR title, this task will run again and the
# warning should go away if you have made acceptable changes.
#
# For more information on Conventional Commits, please see:
#
# https://www.conventionalcommits.org/en/v1.0.0/
#
# ------------ (end of message) ------------
if echo "$PR_TITLE" | grep -E '^chore(\(.*\))?: release '; then
echo "Exception / OK: chore release pattern"
exit 0;
fi
if echo "$PR_TITLE" | grep -E '^chore: release'; then
echo "Exception / OK: chore release pattern"
exit 0;
fi
if echo "$PR_TITLE" | grep -E '^chore(\(deps\))?: bump '; then
echo "Exception / OK: Dependabot update pattern"
exit 0;
fi
echo "Installing commitlint-rs. Please wait 30-40 seconds ..."
cargo install --quiet commitlint-rs
set -e
echo
echo
echo --- commitlint results for PR title \"$PR_TITLE\" ---
echo
# Workaround for https://github.com/KeisukeYamashita/commitlint-rs/issues/355
if echo "$PR_TITLE" | grep -E "^[a-z]+\(.*\): "; then
echo "$PR_TITLE" | commitlint -g .commitlintrc.yml
else
echo "$PR_TITLE" | commitlint -g .commitlintrc.no-scope.yml
fi
echo "✅ PR title matches all enforced rules."