FInally found a solution starting from @mpp’s idea, and an answer in this thread:
-
If this is a private repository, you will need to add a new ssh key in the CI.
-
Fetch the branch you want to merge:
git fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
-
Compare the current commit with the branch you want to merge with:
git diff --name-only $CI_COMMIT_SHA $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
Voilà !