User gh page with custom domain

Hi have the gh page and I want to redirect it to
The problem is that the user page must be built from master. So I’m pushing the react app on the branch ‘develop’ and then I run the scripts to deploy the build to master

npm run build
gh-pages -b master -d build

When I do this the master branch is overridden with the build and the CNAME file is deleted, so my page is not redirecting to my custom domain.
What can I do to keep the CNAME file?

I solved the problem by myself, putting the CNAME file in the folder public of the branch develop, so that when it is built it will go automatically on the root folder.
Do you know any other solution that is better than this?