Prevent the merge request title from being changed after a successful MR pipeline run - squash commit and fast-forward merge

What is the best way to implement this?

The merge request title should have a specific form, as this will subsequently be the commit message due to squash commit and fast-forward merge.

A job runs in the merge request pipeline that lints the MR title and merging is only allowed after a successful pipeline.

But: after the pipeline has run through, a further commit ensures that the pipeline has to run through again successfully, but the change to the MR title does not. This means that it cannot be ensured that the commit message always corresponds to a schema.

Several ideas:

  1. Push rules: Unfortunately, push rules cannot be applied to branches, but only to all of them; there should be no commit rules within the MR itself, as squash commits and fast-forward merges are lost anyway.

  2. Webhook on MR change: I have created a webhook that triggers a new pipeline within the MR when the title is changed. I used jq from the TRIGGER_PAYLOAD to check whether the title has changed and whether the status is set to mergable (.changes.title.previous and .changes.title.current and .object_attributes.detailed_merge_status == "mergeable")). Problem: In the time between the title change and the path Webhook->Pipeline with API request to start the pipeline in the MR, there are still a few seconds where it is still possible to merge.