ci: check that PR titles follow Conventional Commits (#5143)

* ci: check that PR titles follow Conventional Commits

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* ci: address Greptile review on the PR title check

Give the HLTB updater a Conventional Commits title so its PRs pass the
check, and strip line breaks from the title before echoing it so it
cannot start a workflow command.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
Georges-Antoine Assi
2026-10-07 11:52:49 -04:00
committed by GitHub
co-authored by Claude Opus 5.5
parent 9d216401b3
commit dbf5ae94c3
3 changed files with 44 additions and 2 deletions
@@ -0,0 +1,41 @@
name: Conventional PR Title
# The PR title becomes the squash commit and the release notes line, so it
# has to follow Conventional Commits: `type(scope)!: description`.
on:
pull_request:
types: [opened, edited, synchronize, reopened]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
permissions: {}
jobs:
check-title:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Check the PR title
env:
# Read from env, never interpolated into the script, since the title is untrusted.
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
types="feat|fix|perf|refactor|revert|docs|style|test|build|ci|chore"
pattern="^(${types})(\([a-z0-9][a-z0-9._/, -]*\))?!?: [^ ].*$"
if [[ "$PR_TITLE" =~ $pattern ]]; then
echo "PR title follows Conventional Commits."
exit 0
fi
echo "::error::PR title must follow Conventional Commits: type(scope)!: description"
# Line breaks would let the title start a workflow command line.
echo "Got: ${PR_TITLE//[$'\r\n']/ }"
echo "Allowed types: ${types//|/, }"
echo "Examples:"
echo " feat(saves): favorite and label saves and states"
echo " fix: serialize single-file ROM promotion across gunicorn workers"
exit 1
+2 -2
View File
@@ -40,10 +40,10 @@ jobs:
with:
add-paths: |
backend/handler/metadata/fixtures/hltb_api_url
commit-message: "Update HLTB API URL [skip CI]"
commit-message: "chore(hltb): update HLTB API URL [skip CI]"
branch: update-hltb-api-url
sign-commits: true
title: "Update HLTB API URL [skip CI]"
title: "chore(hltb): update HLTB API URL [skip CI]"
reviewers: |
gantoine
+1
View File
@@ -57,6 +57,7 @@ If you would like to translate the project into another language, create a new f
- Update the documentation if necessary.
- Ensure all existing tests pass, and add new tests for new functionality.
- Use clear and descriptive titles and descriptions for your pull requests.
- Write the PR title as a [Conventional Commit](https://www.conventionalcommits.org/), such as `fix(scan): keep partial bytes out of the fallback hash`. Allowed types are `feat`, `fix`, `perf`, `refactor`, `revert`, `docs`, `style`, `test`, `build`, `ci` and `chore`, and CI checks the title.
## Code Style