I want to create an action for a trigger in IBM Cloud Functions, but instead of only adding the code in the console, I want the action to deploy from code on a github repository. How can I do this?
Thanks in advance.
I want to create an action for a trigger in IBM Cloud Functions, but instead of only adding the code in the console, I want the action to deploy from code on a github repository. How can I do this?
Thanks in advance.
Copyright © 2021 Jogjafile Inc.
I don't believe (or at least have not seen anywhere in the docs) you can just point the Cloud Functions to a GitHub repo. With that said you could do the following:
Make sure
ibmcloudCLI is installed and you have the Cloud Functions plugin also installedibmcloud plugin install cloud-functionsibmcloud login- You need a valid session in the CLI or use an IBM Cloud API key or a Service ID key that has the right IAM access to deploy to a Cloud Function namespace in IBM Cloudibmcloud login --apikey "YOUR_API_KEY".ibmcloud target -r eu-gb- You need to target the right region where the Cloud Function will live.ibmcloud target -g test-resource-group- Once logged in, you need to make sure you target the right resource group where the Cloud Function will be pushed too.If you are lazy like me then you can roll all 3 of the above commands into 1 like so:
ibmcloud login --apikey "YOUR_API_KEY" -r "eu-gb" -g "test-resource-group"ibmcloud functions namespace target test-function-namespace- Finally, after logging in you need to use thecloud-functionsplugin to target the right namespace where the Cloud Function will be pushed.There are multiple ways to deploy the Cloud Function. For example, using the CLI to push the cloud function or using a
manifest.ymlfile as a config.Using IBM Cloud CLI
Creating a trigger assuming
test-actionis already created.Using Manifest File
The example below is triggering the
test-actionCloud Function every 15 minutes using a Cloud Function trigger.manifest.yamlTo deploy this you essentially just:
Both options can essentially be wired into a CD tool like Travis or Jenkins and can automatically deploy latest changes to the Cloud from GitHub.