Commit/Merge Request DEV->MASTER create file with commit SHA

Hey folks,

I have multiple repositories and each with different branches. Now - if I do a merge request from dev to master, I would somehow like to automatically create a file ‘version.env’ with the latest COMMIT_SHA. Does anybody know, how to achieve this? This file should be within the repository, because I have to show the commit tag inside my application.

Thanks in advance,
Oliver