I've set up a GitHub Actions workflow that uses commitlint to lint messages for all commits of a pull request, but the problem is that the merge commit is not considered. This action is, in short, as simple as the following:
on: [pull_request]
jobs:
lint-commit-messages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 16
- run: npm install -g @commitlint/{cli,config-conventional}
- run: commitlint --from ${{ github.event.pull_request.base.sha }}
--to ${{ github.event.pull_request.head.sha }}
--verbose
What I need is to stop the pull request merge process when commitlint doesn't accept the merge commit message — the one that is usually written through the browser.
The GitHub Actions docs says something about the GITHUB_SHA
environment variable, which is a reference to the pull request's "future" merge commit, but I didn't find a way to use it.
Do you know how I can proceed? What I need is possible? Other ideas or approaches are welcome.