Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploying each subdirectory of my git repository to a different target with CI/CD

I have a single git repository with multiple projects. The code of each project is found under a dedicated subdirectory. Each project has it's own deploy procedure. I would like that when I push a commit under the project's directory it would deploy the right project (and only it). I am currently using bitbucket pipeline, however, it seems, that it doesn't have this option. How can I make this work? ( I can switch to another CI/CD tool )

like image 319
Alon Avatar asked Oct 15 '22 15:10

Alon


1 Answers

It does not have this option because this is not how git is used.

For projects that are to be separately deployed there should be one repository each. This will allow you to fine tune the deploy procedures individually in a manageable and documentable way and, even more important, keep the history clean. Imagine now in your situation you need to review a specific project's history - you will end up digging though all the commits of the other projects trying to find the ones you are looking for.

There is a solution though if you need the projects interconnected and under common version control: submodules. Check out the official docu here. It will allow you to keep track of individual histories and share resources at the same time. Also it will give you distinct control over the versions of each project being in the shared space.

So my solution to your problem: Refactor. Separate the projects to individual repositories, each with its own deployment strategy working just fine. If you then need to interconnect them and share resources make them submodules, create a new repository and add them in as submodules. This should solve your hickups with a messed up history and uncontrollable folders.

like image 86
harmonica141 Avatar answered Oct 19 '22 23:10

harmonica141