I have to manage different variants of a software (in this case PHP+CSS+JS) in Gitlab for different "customers" (in this case non-profit associations). The differences are limited to a few files (3 files), the rest is the same for all customers. But in these three files I often have to make changes.
Now I want to transport via gitlab CI/CD the respective software + the specific variants of the files to the different servers (for each customer). And always, if I change something at branch main or at a customer-specific file I like to push the changes to the server via gitlab CICD. (For now only to the respective staging system, production only triggered manually).
What is a good and simple way to do this? My first approaches:
- Old-fashioned: One directory per client for these files and then copy them manually per client per shell. Disadvantage: Does not work with repro/git pull on the server (which I currently use), because git would grumble on the next run because of locally modified files. So I would have to change the pipeline to rsync. And that is not a very nice solution...
- Maintain all clients in a separate branch, in the main pipeline do an automatic merge from main to the client branch on delivery (only locally inside the docker container) and push the result to the servers. Problem: The pipeline fails on merge conflicts.
- The commit to main triggers an automatic merge for the corresponding branches. Only these then trigger the appropriate pipelines for each customer. (No experience of doing multiple merges from CI/CD to other branches!) (The difference with the above option is that the push to the server is done in the branch pipeline, not the main pipeline as above).
- Move the three files out to a separate repo per client, separate pipelines.(... too many repo's)
- Create a git patch from the customisations for each client and apply it to the pipeline. Disadvantage: every time a change is made, the patch has to be rebuilt. (Unless I also create it in the pipeline). ... for sure there are more possibilities
I'm familiar with basically git pipelines, so I don't need a complete solution as code (I also like to take) but just a description of the best (or a good) way. For me the 3rd solution (automatic merge in the customer branches) looks best. (even I don't now how to do that)