We are using a mono repository(GCP source repository) which consist of one folder for each cloud function(Cloud function's source code). What we are planning to do is implement a CI/CD pipeline using Cloud build but I would like to know if there is a way to make settings in a such a manner that if I make change in one particular function's source code and commit it then only that code is deployed.
- we have about 50 different codes (it makes 50 folders inside our main repo)
- Each folder consist of requirement.txt , the required .json files and the main.py
I am a newbie to this and implementing CI CD for the first time, pardon me if I am not able to explain my problem in a proper way , any suggestion would be of great help.
Thanks.
UPDATE So as of now by using the below suggested .yaml file am my build step is completing but no function is getting created and I am getting an error in the build logs which am posting below this.
My YAML FILE
- name: 'gcr.io/cloud-builders/gcloud'
entrypoint: 'bash'
args:
- -c
- |
for d in $(git diff --name-only --diff-filter=AMDR @~..@ | cut -d'/' -f 1);
do
echo $d;
cd $d
gcloud functions deploy $d --region=us-central1 --runtime=python37 --trigger-http
cd ..
done
FAIL LOG though the step is showing success=(green) -
FETCHSOURCE
Initialized empty Git repository in /workspace/.git/
From https://source.developers.google.com/p/xyz/r/testRep
* branch 2f78b61ea0cc45efc3e25570fe4a08707 -> FETCH_HEAD
HEAD is now at 2fb61 testing
BUILD
Already have image (with digest): gcr.io/cloud-builders/gcloud
fatal: ambiguous argument '@~..@': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
PUSH
DONE