# The squash-title gate. protect-trunk sets squash_merge_commit_title to
# PR_TITLE, so the pull request's title becomes the trunk's commit message,
# and the bot derives the version and the changelog from that message; this
# check holds the title to a scoped Conventional Commit before the merge is
# offered. The trunk ruleset requires it by the job name pr-title, beside
# the project's own check.
#
# pull_request_target runs the trunk's own copy of this file, so a request
# cannot edit the check it must pass; nothing here checks out or executes
# the request's code, and the title reaches the shell through the
# environment, never through template interpolation.
name: pr-title
on:
pull_request_target:
types:
permissions:
jobs:
pr-title:
name: pr-title
runs-on: ubuntu-latest
steps:
- name: the title is a scoped Conventional Commit
env:
TITLE: ${{ github.event.pull_request.title }}
# The second alternative is the bot's own release request, whose
# title the release automation authors, not an operator.
run: |
printf '%s' "$TITLE" | grep -Eq \
'^((build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)\((RK_SCOPES_PIPE)\)!?: .+|chore(\((release|master|main)\))?: (release|v).+)$' \
&& exit 0
echo "the title '$TITLE' must read type(scope) then a colon and a description, with the scope one of RK_SCOPES_CSV"
exit 1