To set up a CI/CD pipeline for Google Cloud Functions, start by writing your function code and storing it in a version control system like GitHub. Next, create a new project on Google Cloud Platform (GCP) and enable the Cloud Functions API.
Then, navigate to the Cloud Build section of GCP and connect your repository. Create a build trigger that points to your repository and specify the branch or tag to watch for changes. In the build configuration file field, provide the path to your cloudbuild.yaml file which should include steps to deploy your function using gcloud commands.
For continuous deployment, use the ‘gcloud functions deploy’ command in your cloudbuild.yaml file. This will automatically deploy your function whenever you push to the specified branch or tag.
Ensure proper testing is done before deploying to production environments. Use tools like Mocha for unit tests and Postman for integration tests.