Trigger Gitlab CI/CD pipeline to deploy specific part of the repository

Viewed 304

I have a repository on GitLab with a directory structure similar to this:

folder-a\
 -python-a.py\
folder-b\
 -python-b.py

I am trying to set up a CI/CD pipeline on gitlab that will detect changes made to the python code, and deploy them to a production server. What I have currently is the user have to trigger the pipeline manually, and input in the folder name as a variable, which will then cause the pipeline to "cd" into the folder and deploy the code inside the folder.

Is there any configuration or settings that can be added to the pipeline so whenever a Merge Request is merged to the main branch, the pipeline triggers and detects which code was changed, and then deploy the respective code without having the user to manually trigger it and inputting the folder name as a variable?

1 Answers

You might be able to use only:changes / except:changes to do that.

You can have two jobs. One job that goes to folder-a if something under folder-a/* has changed and the other job goes to folder-b if something under folder-b/* has changed.

Related