Menu
In this article, we have seen how we can enforce a commit message checker on users of a project using a combination of the pre-commit framework and GitHub Actions. pre-commit can check things on the users’ local repositories, but the user has to remember to install the hook scripts with pre-commit install
. To ensure that unchecked code is not pushed to the main branch, you can setup a workflow in your remote repository to run the checks again.
An example of a commit message checker is provided in EmLogic’s git-hooks repository, which you are welcome to use yourself or take inspiration from. At the time of writing, this repository provides pre-commit hooks for both checking commit messages, and for applying a git message template when you commit. It also provides a GitHub Action for checking commit messages in your CI pipelines.