Search code examples
azure-devopsgatsbygithub-pages

Github Pages loose setting for custom domain each time I push to the repo


As the title says, each time I push to my Github Pages repository it looses the settings for the custom domain. Why is that?

I am having two repositories for my static blog. The first one is hosted on AzureDevops and private. It contains all the source code of my gatbsy site. The second one is the public repo at Github.

This is the deployment script I am using on AzureDevops to push to my github repo

git init 
git config --global user.email "[email protected]"
git config --global user.name "My name"
git remote add origin $(GitHubPagesRepo)
git add . 
git commit -am $Env:Release_ReleaseName
git push origin master --force

The variable $(GitHubPagesRepo) holds https://<my token>@github.com/myuser/myuser.github.io.git

Any ideas?


Solution

  • Found the reason! Due to the force push I always lost the CNAME file in the repository which is required for the custom domain to work.

    https://help.github.com/en/github/working-with-github-pages/troubleshooting-custom-domains-and-github-pages#cname-errors