I have three subprojects (Angular and Node.js) in the same GitLab project. Now I want to create the gitlab-ci.yml file for building and deploying one of this subprojects. Can I create three different gitlab-ci.yml files and run them inside subdirectories? Is it possible? Or should I push those into three different projects?

My personal preference is to keep projects small. So I usually create one GitLab project per, e.g., module, library, program, design, etc.
But if you really wanted to, you could easily either:
Create a single .gitlab-ci.yml that goes something like:
my_job:
stage: test
script:
- |
cd "$CI_PROJECT_DIR/folder1"
< do stuff >
cd "$CI_PROJECT_DIR/folder2"
< do stuff>
...
Create multiple gitlab-ci configurations inside the folders and include them in the root .gitlab-ci.yml file
include:
- 'folder1/pipeline.yml'
- 'folder2/pipeline.yml'
Note that when using the second option, you will still have to cd folderX since pipelines always start in the repository's root directory, no matter from where they are imported.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With