Instead of doing staging in a separate branch, I do it in a separate GitHub repo.
Keeping a separate branch with separate staging configs, staging CNAME
and DNS files, and staging-specific features is a hassle within the same repo. Separate repos is a simpler solution since it maintains the mental model that development and staging are different environments.
So there's 2 GitHub repos: a main and a staging repo. GitHub Pages settings allows for separate DNS settings. Since I have a custom domain, the main repo is set to www.customDomain.com
and staging repo is set to staging.customDomain.com
.
Here's my setup using Main
and Staging
repo names. Staging
is set as a remote for Main
, and Staging
is an exact copy of Main
(besides configs, CNAME
, staging-specific features, etc...).
GitHub Pages builds the site using the master
branch in Main
. I use a dev
branch in Main
to hold the new code and features. Development work is done in feature branches that branch off of dev
and are merged back into dev
. When I want to test the feature in Staging
, I go to Staging
and pull in the latest version of the Main:dev
branch. After I'm done testing in Staging
, then I'll pull Main:dev
into Main:master
.
Here's a diagram if that helps you understand the setup. Hopefully this answers your question.
Main Staging
| | |
| | |
|\ | |
| \ | |
| \| |
| | |
| | |
| |\ |
| | \ |
| | \ |
| | \ |
| | \ |
| | \ |
| | \|
| | |
| | |
| | /|
| | / |
| | / |
| | / |
| | / |
| | / |
| |/ |
| | Staging:master
| |\
| | \
| | \
| | |
| | |
| | /feature
| | /
| |/
| |
| /dev
| /
|/
|
Main:master