'Different versions of configuration files on remote github repositories (staging/production)
I am setting up a documentation website, using GitHub Pages + Docusaurus (static website generator).
There are two github repositories involved: "DOCS" for the staging version of the website (dev.docs.com) and "DOCS-PRODUCTION" for hosting the production version (docs.com). All the "magic" happens in "DOCS" repository, devs clone it, push, pull, etc. When it's ready for a 'release', the idea is to do git push production main
and have the latest version live.
However, some (configuration) files need to be different for staging ("DOCS" repo) and production ("DOCS-PRODUCTION") versions of the website. How to achieve this?
I've seen the hijacking method using the git update-index --assume-unchanged <filename>
, but don't know how to apply it in my situation. Steps I've done so far:
- create empty "DOCS" github repository
- create empty "DOCS-PRODUCTION" github repository
- create simple website; git init;
git add remote origin <DOCS URL>
; git push git add remote production <DOCS-PRODUCTION URL>
How to go from here in order to have one version of the config file in the staging repo and a different, "fixed" version of config in the production repo?
Solution 1:[1]
Instead of "messing around" with git, I chose a simpler and probably cleaner approach using CI/CD (Github Actions):
Keep both versions of config files in the repository (staging and production)
By using Github Actions, copy/rename the appropriate config file depending on the name of the repository. E.g. if repo name is DOCS-PRODUCTION take the prouction config file and rename it into "configuration.js" (which is expected by the framework we use). Otherwise take the staging version of the docs.
Seems cleaner and it works.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Jurc192 |