11name : Deploy or update Code Engine workloads
2- description : Github action to create or update applications, batch jobs and serverless functions in IBM Cloud Code Engine
2+ description : Github action to create or update IBM Cloud Code Engine applications, batch jobs and serverless functions
33author : Ryan Tiffany
44
55branding :
@@ -14,23 +14,24 @@ inputs:
1414 resource_group :
1515 description : The IBM Cloud Resource Group associated with the Code Engine project.
1616 required : false
17- default : Default
17+ default : " Default"
1818
1919 code_engine_region :
2020 description : The Region where the Code Engine project is located.
2121 required : true
22+ default : " us-south"
2223
2324 code_engine_project :
24- description : The name of the Code Engine Project where the workload is deployed.
25+ description : The name of the Code Engine Project where the workload will be deployed.
2526 required : true
2627
27- # App, Function or Job Specific inputs
28+ # Workload Specific inputs
2829 workload_type :
29- description : The code engine workload type that should be created or updated [App, Function, Job]
30+ description : The code engine workload type that should be created or updated.
3031 required : true
3132
3233 workload_name :
33- description : Name of the App, Function or Job
34+ description : Name of the application, job or function
3435 required : true
3536
3637 function_runtime :
@@ -43,25 +44,24 @@ inputs:
4344 default : .
4445
4546 workload_cpu :
46- description : CPU configuration set for the workload. If not set default Code Engine values are used.
47+ description : CPU configuration for the workload. If not set the default Code Engine value is used.
4748 required : false
48- default : 1
49+ default : " 1 "
4950
5051 workload_memory :
51- description : Memory configuration set for the workload. If not set default Code Engine values are used.
52+ description : Memory configuration for the workload. If not set the default Code Engine value is used.
5253 required : false
53- default : 4G
54+ default : " 4G "
5455
5556 workload_port :
56- description : Port configuration set for the app workload_type. If not set default Code Engine values are used.
57+ description : Port configuration for the app workload_type. If not set the default Code Engine value is used.
5758 required : false
58- default : 8080
59+ default : " 8080"
5960
6061 workload_arg :
6162 description : Additional arguments to add to the app or job
6263 required : false
6364
64-
6565# Github action code
6666runs :
6767 using : composite
@@ -72,16 +72,15 @@ runs:
7272 shell : bash
7373 run : curl -fsSL https://clis.cloud.ibm.com/install/linux | sh
7474
75- - name : Login to IBM Cloud And target Resouce Groupe and Region
75+ - name : Login to IBM Cloud and target target region and resource group for code engine deployment
7676 shell : bash
7777 run : ibmcloud login --apikey ${{ inputs.ibmcloud_api_key }} -r ${{ inputs.code_engine_region }} -g ${{ inputs.resource_group }}
7878
7979 - name : Install Code Engine Plugin
8080 shell : bash
8181 run : ibmcloud plugin install code-engine
8282
83- # Select the project using Name or ID
84- # If the project doesn`t exist , it will be created project with the provided `code_engine_project` name
83+ # Select or create Code Engine Project
8584 - name : Select Code Engine Project
8685 shell : bash
8786 run : |
9190 ibmcloud ce project create --name ${{ inputs.code_engine_project }}
9291 fi
9392
94- # set resources for target
95- - name : Set resources
96- id : set-resources
93+ # Set cpu, memory, and custom arg defaults for workloads
94+ - name : Set workload resources
95+ id : set_workload_resources
9796 shell : bash
9897 run : |
9998 # set the CPU value
@@ -110,43 +109,50 @@ runs:
110109 echo "workload_memory=" >> "$GITHUB_OUTPUT"
111110 fi
112111
113- # Functions Steps
114- - name : Create or Update Functions
112+ # set the arg value
113+ if [[ "${{ inputs.workload_arg }}" != "" ]] ; then
114+ echo "workload_arg=--arg ${{ inputs.workload_arg }}" >> "$GITHUB_OUTPUT"
115+ else
116+ echo "workload_arg=" >> "$GITHUB_OUTPUT"
117+ fi
118+
119+ # Functions deployment or update steps
120+ - name : Create or update code engine serverless function
115121 shell : bash
116122 id : ce-fn
117123 if : ( inputs.workload_type == 'function' || inputs.workload_type == 'func' || inputs.workload_type == 'fn' )
118124 run : |
119125
120126 if ibmcloud ce fn get --name ${{ inputs.workload_name }} ; then
121- ibmcloud ce fn update --name ${{ inputs.workload_name }} --runtime ${{ inputs.function_runtime }} --build-source ${{ inputs.build_source }} ${{ steps.set-resources .outputs.workload_cpu }} ${{ steps.set-resources .outputs.workload_memory }}
127+ ibmcloud ce fn update --name ${{ inputs.workload_name }} --runtime ${{ inputs.function_runtime }} --build-source ${{ inputs.build_source }} ${{ steps.set_workload_resources .outputs.workload_cpu }} ${{ steps.set_workload_resources .outputs.workload_memory }}
122128 else
123- ibmcloud ce fn create --name ${{ inputs.workload_name }} --runtime ${{ inputs.function_runtime }} --build-source ${{ inputs.build_source }} ${{ steps.set-resources .outputs.workload_cpu }} ${{ steps.set-resources .outputs.workload_memory }}
129+ ibmcloud ce fn create --name ${{ inputs.workload_name }} --runtime ${{ inputs.function_runtime }} --build-source ${{ inputs.build_source }} ${{ steps.set_workload_resources .outputs.workload_cpu }} ${{ steps.set_workload_resources .outputs.workload_memory }}
124130 fi
125131
126- # Application Steps
127- - name : Create or Update Application
132+ # Application deployment or update steps
133+ - name : Create or update code engine application
128134 shell : bash
129135 id : ce-app
130136 if : ( inputs.workload_type == 'application' || inputs.workload_type == 'app' )
131137 run : |
132138
133139 if ibmcloud ce application get --name ${{ inputs.workload_name }} ; then
134- ibmcloud ce application update --name ${{ inputs.workload_name }} --build-source ${{ inputs.build_source }} ${{ steps.set-resources .outputs.workload_cpu }} ${{ steps.set-resources .outputs.workload_memory }} --port ${{ inputs.workload_port }}
140+ ibmcloud ce application update --name ${{ inputs.workload_name }} --build-source ${{ inputs.build_source }} ${{ steps.set_workload_resources .outputs.workload_cpu }} ${{ steps.set_workload_resources .outputs.workload_memory }} --port ${{ inputs.workload_port }} ${{ steps.set_workload_resources.outputs.workload_arg }}
135141 else
136- ibmcloud ce application create --name ${{ inputs.workload_name }} --build-source ${{ inputs.build_source }} ${{ steps.set-resources .outputs.workload_cpu }} ${{ steps.set-resources .outputs.workload_memory }}
142+ ibmcloud ce application create --name ${{ inputs.workload_name }} --build-source ${{ inputs.build_source }} ${{ steps.set_workload_resources .outputs.workload_cpu }} ${{ steps.set_workload_resources .outputs.workload_memory }} ${{ steps.set_workload_resources.outputs.workload_arg }}
137143 fi
138144
139- # Job Steps
140- - name : Create or Update Job
145+ # Job deployment or update steps
146+ - name : Create or update code engine job
141147 shell : bash
142148 id : ce-job
143149 if : inputs.workload_type == 'job'
144150 run : |
145151
146152 if ibmcloud ce job get --name ${{ inputs.workload_name }} ; then
147- ibmcloud ce job update --name ${{ inputs.workload_name }} --build-source ${{ inputs.build_source }} --wait ${{ steps.set-resources .outputs.workload_cpu }} ${{ steps.set-resources .outputs.workload_memory }}
153+ ibmcloud ce job update --name ${{ inputs.workload_name }} --build-source ${{ inputs.build_source }} --wait ${{ steps.set_workload_resources .outputs.workload_cpu }} ${{ steps.set_workload_resources .outputs.workload_memory }} ${{ steps.set_workload_resources.outputs.workload_arg }}
148154 else
149- ibmcloud ce job create --name ${{ inputs.workload_name }} --build-source ${{ inputs.build_source }} --wait ${{ steps.set-resources .outputs.workload_cpu }} ${{ steps.set-resources .outputs.workload_memory }}
155+ ibmcloud ce job create --name ${{ inputs.workload_name }} --build-source ${{ inputs.build_source }} --wait ${{ steps.set_workload_resources .outputs.workload_cpu }} ${{ steps.set_workload_resources .outputs.workload_memory }} ${{ steps.set_workload_resources.outputs.workload_arg }}
150156 fi
151157
152158 - name : Get workload_type
0 commit comments