|
| 1 | +# Code Engine Deploy GitHub Action |
| 2 | + |
| 3 | +This GitHub Action allows you to Create or update Code Engine Apps, Jobs, and Functions in IBM Cloud. |
| 4 | + |
| 5 | +It offers flexibility for different deployment types and provides various configuration options. |
| 6 | + |
| 7 | +## Author |
| 8 | + |
| 9 | +- Author: Ryan Tiffany |
| 10 | + |
| 11 | +## Description |
| 12 | + |
| 13 | +This action allows you to create or update IBM Cloud Code Engine workloads. It supports deploying applications, jobs, and functions and can be configured with the following inputs: |
| 14 | + |
| 15 | +### Inputs |
| 16 | + |
| 17 | +| Name | Required | Default Value |Description | |
| 18 | +|-----------------|----------|---------------|----------------------------------------------------------------| |
| 19 | +| `ibmcloud_api_key` | ✅ | - | IBM Cloud API Key. Please store your IBM Cloud API key securely in your GitHub repository Secrets.| |
| 20 | +| `resource_group` | ✅ | - | An IBM Cloud Resource Group, a logical container for organizing and managing related cloud resources.| |
| 21 | +| `code_engine_region` | ✅ | - | The geographical area where your Code Engine project is located.| |
| 22 | +| `code_engine_project` | ✅ | - | A Code Engine Project, grouping your Apps, Functions, and Jobs.| |
| 23 | +| `workload_type` | ✅ | - | The type of workload to create or update (App, Function, Job). | |
| 24 | +| `workload_name` | ✅ | - | The name of the App, Function, or Job.| |
| 25 | +| `function_runtime` | ❌ | - | The runtime used for the Function. Currently supported `nodejs-18` and `python-3.11` see [IBM Code Engine Function Runtimes](https://cloud.ibm.com/docs/codeengine?topic=codeengine-fun-runtime) for more information.| |
| 26 | +| `build_source` | ❌ | . | Path to the directory containing the source code.| |
| 27 | +| `workload_cpu` | ❌ | - | CPU configuration for your workload. If not specified the Code Engine default is used. | |
| 28 | +| `workload_memory` | ❌ | - | Memory configuration for your workload. If not specified the Code Engine default is used. | |
| 29 | +| `workload_port` | ❌ | 8080 | Port configuration for your app workloads | |
| 30 | + |
| 31 | + |
| 32 | +## Usage |
| 33 | + |
| 34 | +To use this action add it to your GitHub Actions workflow YAML file. Here are examples of how to create or update an App, Job, and Function: |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | +```yaml |
| 39 | +name: Create or update workload in IBM Cloud Code Engine |
| 40 | + |
| 41 | +on: |
| 42 | + push: |
| 43 | + branches: |
| 44 | + - main |
| 45 | + |
| 46 | +env: |
| 47 | + CODE_ENGINE_REGION: "us-south" |
| 48 | + CODE_ENGINE_PROJECT: "Code Engine Project Name" |
| 49 | + WORKLOAD_NAME: "my-cool-app" |
| 50 | + |
| 51 | +jobs: |
| 52 | + |
| 53 | + code-engine-app: |
| 54 | + runs-on: ubuntu-latest |
| 55 | + steps: |
| 56 | + - name: Check out code |
| 57 | + uses: actions/checkout@v3 |
| 58 | + |
| 59 | + - name: Deploy Application to Code Engine |
| 60 | + uses: cloud-design-dev/ibmcloud-code-engine-github-action@v1 |
| 61 | + with: |
| 62 | + ibmcloud_api_key: ${{ secrets.IBMCLOUD_API_KEY }} |
| 63 | + resource_group: 'Default' |
| 64 | + code_engine_region: ${{ env.CODE_ENGINE_REGION }} |
| 65 | + code_engine_project: ${{ env.CODE_ENGINE_PROJECT }} |
| 66 | + workload_type: 'app' |
| 67 | + workload_name: ${{ env.WORKLOAD_NAME }} |
| 68 | + workload_port: 8080 |
| 69 | + build_source: './app-code' |
| 70 | + cpu: 1 |
| 71 | + memory: 4G |
| 72 | + |
| 73 | + code-engine-job: |
| 74 | + runs-on: ubuntu-latest |
| 75 | + steps: |
| 76 | + - name: Check out code |
| 77 | + uses: actions/checkout@v3 |
| 78 | + |
| 79 | + - name: Deploy Job to Code Engine |
| 80 | + uses: skywalkeretw/ibm-code-engine-github-action@v1 |
| 81 | + with: |
| 82 | + ibmcloud_api_key: ${{ secrets.IBMCLOUD_API_KEY }} |
| 83 | + resource_group: 'Default' |
| 84 | + code_engine_region: ${{ env.CODE_ENGINE_REGION }} |
| 85 | + code_engine_project: ${{ env.CODE_ENGINE_PROJECT }} |
| 86 | + workload_type: 'job' |
| 87 | + workload_name: ${{ env.WORKLOAD_NAME }} |
| 88 | + build_source: './job-code' |
| 89 | + cpu: 1 |
| 90 | + memory: 4G |
| 91 | + |
| 92 | + code-engine-fn-js: |
| 93 | + runs-on: ubuntu-latest |
| 94 | + steps: |
| 95 | + - name: Check out code |
| 96 | + uses: actions/checkout@v3 |
| 97 | + |
| 98 | + - name: Deploy JavaScript Function to Code Engine |
| 99 | + uses: skywalkeretw/ibm-code-engine-github-action@v1 |
| 100 | + with: |
| 101 | + ibmcloud_api_key: ${{ secrets.IBMCLOUD_API_KEY }} |
| 102 | + resource_group: 'Default' |
| 103 | + code_engine_region: ${{ env.CODE_ENGINE_REGION }} |
| 104 | + code_engine_project: ${{ env.CODE_ENGINE_PROJECT }} |
| 105 | + workload_type: 'fn' |
| 106 | + function_runtime: 'nodejs-18' |
| 107 | + workload_name: ${{ env.WORKLOAD_NAME }} |
| 108 | + build_source: './fn-js-code' |
| 109 | + cpu: 1 |
| 110 | + memory: 4G |
| 111 | + |
| 112 | + code-engine-fn-py: |
| 113 | + runs-on: ubuntu-latest |
| 114 | + steps: |
| 115 | + - name: Check out code |
| 116 | + uses: actions/checkout@v3 |
| 117 | + |
| 118 | + - name: Deploy JavaScript Function to Code Engine |
| 119 | + uses: skywalkeretw/ibm-code-engine-github-action@v1 |
| 120 | + with: |
| 121 | + ibmcloud_api_key: ${{ secrets.IBMCLOUD_API_KEY }} |
| 122 | + resource_group: 'Default' |
| 123 | + code_engine_region: ${{ env.CODE_ENGINE_REGION }} |
| 124 | + code_engine_project: ${{ env.CODE_ENGINE_PROJECT }} |
| 125 | + workload_type: 'fn' |
| 126 | + function_runtime: 'python-3.11' |
| 127 | + workload_name: ${{ env.WORKLOAD_NAME }} |
| 128 | + build_source: './fn-python-code' |
| 129 | + cpu: 1 |
| 130 | + memory: 4G |
| 131 | + |
| 132 | +``` |
| 133 | + |
| 134 | +This action is not officially endorsed by IBM Cloud but can be used as a community-contributed GitHub Action. |
0 commit comments