|
| 1 | +name: PR title |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [opened, synchronize, reopened, edited] |
| 6 | + |
| 7 | +jobs: |
| 8 | + title_cc_validation: |
| 9 | + name: Conventional commits validation |
| 10 | + runs-on: ubuntu-latest |
| 11 | + |
| 12 | + steps: |
| 13 | + - name: Checkout repository |
| 14 | + uses: actions/checkout@v4 |
| 15 | + |
| 16 | + # If changing this, please also see `.commitlintrc` and |
| 17 | + # `docs/release-process.md`. |
| 18 | + |
| 19 | + - name: Check PR title |
| 20 | + env: |
| 21 | + PR_TITLE: ${{ github.event.pull_request.title }} |
| 22 | + run: | |
| 23 | + # If this step fails, please expand this step for more information. |
| 24 | + # |
| 25 | + # You will need to revise this pull request's title to |
| 26 | + # match the "summary" (first) line of a Conventional Commit message. |
| 27 | + # This enables us to automatically generate a meaningful changelog. |
| 28 | + # |
| 29 | + # The summary line (and thus the PR title) must have this exact format |
| 30 | + # (including punctuation): |
| 31 | + # |
| 32 | + # type: description |
| 33 | + # |
| 34 | + # `type` describes the nature of changes you are making. This project |
| 35 | + # requires the type to be one of these exact names: |
| 36 | + # |
| 37 | + # * fix |
| 38 | + # * feat (will cause a minor version bump) |
| 39 | + # * chore (will be omitted from changelog) |
| 40 | + # * update |
| 41 | + # * doc |
| 42 | + # |
| 43 | + # `description` is a short human-readable summary of the changes being made. |
| 44 | + # It is required. |
| 45 | + # |
| 46 | + # This project does not currently enforce the following items, but |
| 47 | + # we ask that you observe the following preferences in `description`: |
| 48 | + # |
| 49 | + # * The entire description should be written and capitalized as |
| 50 | + # an English-language sentence, except that the trailing period |
| 51 | + # should be omitted. |
| 52 | + # * Any acronyms such as JSON or YAML should be capitalized as per |
| 53 | + # common usage in English-language sentences. |
| 54 | + # |
| 55 | + # After you edit the PR title, this task will run again and the |
| 56 | + # warning should go away if you have made acceptable changes. |
| 57 | + # |
| 58 | + # For more information on Conventional Commits, please see: |
| 59 | + # |
| 60 | + # https://www.conventionalcommits.org/en/v1.0.0/ |
| 61 | + # |
| 62 | + # ------------ (end of message) ------------ |
| 63 | +
|
| 64 | + if echo "$PR_TITLE" | grep -E '^chore(\(.*\))?: release '; then |
| 65 | + echo "Exception / OK: chore release pattern" |
| 66 | + exit 0; |
| 67 | + fi |
| 68 | +
|
| 69 | + if echo "$PR_TITLE" | grep -E '^chore: release'; then |
| 70 | + echo "Exception / OK: chore release pattern" |
| 71 | + exit 0; |
| 72 | + fi |
| 73 | +
|
| 74 | + if echo "$PR_TITLE" | grep -E '^chore(\(deps\))?: bump '; then |
| 75 | + echo "Exception / OK: Dependabot update pattern" |
| 76 | + exit 0; |
| 77 | + fi |
| 78 | +
|
| 79 | + if echo "$PR_TITLE" | grep -E '^update: update '; then |
| 80 | + echo "Exception / OK: Dependabot update pattern" |
| 81 | + exit 0; |
| 82 | + fi |
| 83 | +
|
| 84 | + if echo "$PR_TITLE" | grep -E '^update: bump '; then |
| 85 | + echo "Exception / OK: Dependabot update pattern" |
| 86 | + exit 0; |
| 87 | + fi |
| 88 | +
|
| 89 | + echo "Installing commitlint-rs. Please wait 30-40 seconds ..." |
| 90 | + cargo install --quiet commitlint-rs |
| 91 | + set -e |
| 92 | +
|
| 93 | + echo |
| 94 | + echo |
| 95 | + echo --- commitlint results for PR title \"$PR_TITLE\" --- |
| 96 | + echo |
| 97 | +
|
| 98 | + echo "$PR_TITLE" | commitlint -g .commitlintrc.yml |
| 99 | +
|
| 100 | + echo "✅ PR title matches all enforced rules." |
0 commit comments