Problem
My ‘GitHub Pages’ website keeps losing its custom url every time I push a new version! ๐
Background
I had originally used git hub actions to deploy my site based off of foosel’s work. Then I thought:
Hey, I have a local gitlab instance that I just set up a CI runner on… so lets see if I can use that pipeline and have it push a fully build website to GitHub!
I then found when the website was updating it was losing its CNAME setting in GitHub pages settings web ui. I thought I can keep an eye on that and fix it when needed.
Then I noticed a grammatical mistake and quickly updated it while I was settling the kids down and got distracted so forgot to check and fix it…
Cause
Turns out that when you configure a customdomain in GitHub pages using Deploy from a branch it actually adds a CNAME file to the root of your repository with the domain name in it. Of course I hadn’t included this file in my build pipeline so every deployment the web UI created CNAME file was ๐ฅOBLITERATED๐ฅ
Fix
Simple, add create a CNAME file in the root of the built website to the build pipeline before I commit and push it to GitHub.
echo 'ben.sycha.uk' > ${OUTPUT_DIR}/CNAME