I have a project folder with different cloud functions folders e.g.
Project_Folder
-Cloud-Function-Folder1
-main.py
-requirements.txt
-cloudbuild.yaml
-Cloud-Function-Folder2
-main.py
-requirements.txt
-cloudbuild.yaml
-Cloud-Function-Folder3
-main.py
-requirements.txt
-cloudbuild.yaml
--------- and so on!
Now what i have right now is. I push the code to the Source Repository one by one from the Cloud Fucntions folder to Source Repository(Separate Repos for each function folder). And then it has a Trigger enabled which trigger the cloud-build and then deploy the function. The cloudbuild.yaml file i have is like this below..
steps:
- name: 'python:3.7'
entrypoint: 'bash'
args:
- '-c'
- |
pip3 install -r requirements.txt
pytest
- name: 'gcr.io/cloud-builders/gcloud'
args:
- functions
- deploy
- Function
- --runtime=python37
- --source=.
- --entry-point=function_main
- --trigger-topic=Function
- --region=europe-west3
Now, what I would like to do is I would like to make a single source repo and whenever i change the code in one cloud function and push it then only it get deploys and rest remains like before.
Update
Now i have also tried something like this below but it also deploy all the functions at the same time even though i am working on a single function.
Project_Folder
-Cloud-Function-Folder1
-main.py
-requirements.txt
-Cloud-Function-Folder2
-main.py
-requirements.txt
-Cloud-Function-Folder3
-main.py
-requirements.txt
-cloudbuild.yaml
-requirements.txt
cloudbuild.yaml file looks like this below
steps:
- name: 'python:3.7'
entrypoint: 'bash'
args:
- '-c'
- |
pip3 install -r requirements.txt
pytest
- name: 'gcr.io/cloud-builders/gcloud'
args:
- functions
- deploy
- Function1
- --runtime=python37
- --source=./Cloud-Function-Folder1
- --entry-point=function1_main
- --trigger-topic=Function1
- --region=europe-west3
- name: 'gcr.io/cloud-builders/gcloud'
args:
- functions
- deploy
- Function2
- --runtime=python37
- --source=./Cloud-Function-Folder2
- --entry-point=function2_main
- --trigger-topic=Function2
- --region=europe-west3