It wasn’t long after I got my blog working that I wanted to make changes that could break the whole thing. Time to set up a test/dev instance!

Connecting Branch to (production) App

The easiest way is to follow the prompt at the top, once the master branch is set up:

Clicking Set up a test version of your site by connecting a feature branch, gives the option to choose the branch:

After the branch is chosen, a new instance is available:

Note how the test instance is using the default test.*amplify.com domain. The themes that I’m using require a domain name.

Here’s my first attempt at fixing this:

Here’s the NameCheap config:

// before the change:

$ ping test.sourceapprentice.com

ping: cannot resolve test.sourceapprentice.com: Unknown host

// after a few minutes:

$ ping test.sourceapprentice.com

PING d1qzcdre2mr5ze.amplifyapp.com (143.204.158.70): 56 data bytes

64 bytes from 143.204.158.70: icmp_seq=0 ttl=246 time=43.013 ms

And, of course:

Success!

With that out of the way, however, there is a wrinkle in this solution, that does not fit my requirements: There is only one ‘Build settings’ option for the entire app, and I want to be able to work on new themes for the test instance, which is controlled in build settings.

So, onward to the next attempt.

Creating New App for Test Site

I appreciate the info/warning, above. It tells me I’m on the right track.

I was then able to specify my build settings as desired.

But the build was a little odd. I wonder if that will cause an issue on the 77th build …

The first thing I noticed after following the above steps was that everything was working. … but I’m not sure that it should be, at this point. When I added the test branch to the (production) app earlier, it didn’t work, until after I set up the test.sourceapprentice.com domain.

I went to build it again, this time with the old theme, which I’m pretty sure won’t work if the domain doesn’t match. It appeared that it just wouldn’t rebuild. But after refreshing the screen, I was able to restart the build, and I discovered that some kind of self-correction appeared to have been made:

Sure enough, switching to dark mode didn’t work. I’ll use this as my litmus test. First I need to change the subdomain for the (production) app off of the subdomain I plan on using for test:

Along with the matching NameCheap config:

(The new CNAME value matches the default host for the new test app.)

After disabling for the root, and inputting the test subdomain:

… it was time to wait:

… and wait a little more:

… but I hate waiting, so of course I’m going to check early:

I was able to switch themes on test2 …

… while having a different theme on test. … One more test left:

Finally:

And now that I’ve got a ‘real’ test environment not at all connected to my live site, I’m changing the Hugo build command to include future posts and drafts:

- hugo -t min_night --buildFuture --buildDrafts --config config.toml,config.sa.toml