Interconnecting CAE with GitHub Actions to Implement Automatic CI/CD Deployment
In modern software development, continuous integration and continuous deployment (CI/CD) enhance efficiency and ensure quality. Interconnecting CAE with GitHub Actions automates code build, test, and deployment, simplifying the process, reducing human errors, and speeding up software delivery.
Prerequisites
- You have signed up for a HUAWEI ID and enabled Huawei Cloud services and logged in.
- You have created a project, environment, application, and component on the CAE console and obtained the corresponding IDs. Otherwise, see Experiencing CAE Hosting by Deploying a Demo Application to create an environment, application, and component, and Obtaining the Project ID, Region ID, Environment ID, Application ID, and Component ID to obtain the IDs.
- You have registered an account on the GitHub official website, created a GitHub repository, and configured code version management.
- You have generated and kept the access key ID (AK) and secret access key (SK) of Huawei Cloud. In this section, you need to configure them as the secrets of the GitHub repository. For details, see How Do I Obtain an Access Key (AK/SK)?
- You have obtained the login command of the SoftWare Repository for Container (SWR) and configured it as the secrets of the GitHub repository. For details, see Obtaining a Long-Term Login or Image Push/Pull Command.
CI/CD Operation Process
The basic operation process of CI/CD is as follows:

- CI
- When a developer pushes code to the main branch (or a specified branch), GitHub Actions is automatically triggered.
- Build code to generate deployable artifacts (such as container images). For containerized applications, use the Dockerfile to build an image and push the image to the container image repository (for example, swr.me-east-1.myhuaweicloud.com in the example configuration in this section).
- CD
- After the CI is complete, the CD process is triggered.
- Use the configured huaweicloud/cae-deploy@main plugin to deploy the built image to a specified CAE environment and wait until the task is complete.
GitHub Actions Plug-ins
|
Parameter |
Description |
|---|---|
|
ak |
Access key ID (AK) of Huawei Cloud, which is used for identity authentication. |
|
sk |
Secret access key (SK) corresponding to the access key ID, which is used for identity authentication. |
|
project-id |
Project ID of the Huawei Cloud account for deploying CAE components. |
|
region-id |
Huawei Cloud region ID. In this example, the region is me-east-1. |
|
environment-id |
ID of the target environment. |
|
application-id |
Application ID. |
|
component-id |
Component ID. |
|
image-address |
Address of the container image, which is used to specify the image to be deployed. The format is swr.[Region project name].myhuaweicloud.com/[Organization name]/[Image name]:[Version name]. In this example, the region project name is region-id. In this section, image-address is swr.me-east-1.myhuaweicloud.com/demo-cae/cae-frontend:1.0.0. |
|
component-version |
Component version, which is used for version management and rollback. |
Step 1: Configure Secrets for GitHub Actions
To securely use access keys and access sensitive information, you need to configure secrets in the GitHub repository.
In this section, you need to add the access key ID, SK, and image repository login command to GitHub Actions secrets.
After the configuration is complete, GitHub Actions can obtain the sensitive information using ${{ secrets.HUAWEI_SECRET_ACCESS_KEY }}, ${{ secrets. HUAWEI_SECRET_SECRET_KEY }}, and ${{ secrets. HUAWEI_DOCKER_SECRE }} in the runtime, without exposing the information in the configuration file.
- Go to the GitHub repository and click the Settings tab.
- Choose Secrets and variables > Actions.
- Click New repository secret to create a secret named HUAWEI_SECRET_ACCESS_KEY.
Enter HUAWEI_SECRET_ACCESS_KEY in the Name field, enter the actual Huawei Cloud access key ID in the Secret field, and click Add secret.
- Click New repository secret again to create a secret named HUAWEI_SECRET_SECRET_KEY.
Enter HUAWEI_SECRET_SECRET_KEY in the Name field, enter the actual Huawei Cloud access key in the Secret field, and click Add secret.
- Click New repository secret again to create a secret named HUAWEI_DOCKER_SECRET.
Enter HUAWEI_DOCKER_SECRET in the Name field, enter the actual SWR login key in the Secret field, and click Add secret.
- View the created secrets in the Repository secrets list.

Step 2: Configure the GitHub Actions Workflow File and View the Running Result
The following example shows how to use Huawei Cloud CLI to configure a GitHub Actions workflow file for automatically building, testing, packaging, and deploying a Node.js application to CAE. Adjust the configuration as required.
name: Node.js Package
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
cache: npm
cache-dependency-path: node_modules/.package-lock.json
node-version: 16
- name: npm install and build
run: |
chmod 777 node_modules/.bin/vue-cli-service
npm install
npm run build
- name: npm install and build
run: |
chmod 777 node_modules/.bin/vue-cli-service
npm install
npm run build
- name: build images
run: docker build -t cae-frontend:1.0.0 .
- name: Login to SWR
run: docker login -u me-east-1@${{ secrets.HUAWEI_SECRET_ACCESS_KEY}} -p ${{ secrets.HUAWEI_DOCKER_SECRET }} swr.me-east-1.myhuaweicloud.com
- name: Push to SWR
run: |
docker tag cae-frontend:1.0.0 swr.me-east-1.myhuaweicloud.com/demo-cae/cae-frontend:1.0.0
docker push swr.me-east-1.myhuaweicloud.com/demo-cae/cae-frontend:1.0.0
# Download and install Huawei Cloud CLI.
- name: Install HuaweiCloud CLI
run: |
curl -sSL https://cn-north-4-hdn-koocli.obs.cn-north-4.myhuaweicloud.com/cli/latest/hcloud_install.sh -o ./hcloud_install.sh && sudo bash ./hcloud_install.sh -y
# Configure Huawei Cloud CLI.
- name: Configure HuaweiCloud CLI
run: |
sudo hcloud configure set --cli-profile=testAKSK --cli-mode=AKSK --cli-region=me-east-1 --cli-access-key={{ secrets.HUAWEI_SECRET_ACCESS_KEY}} --cli-secret-key={{ secrets.HUAWEI_SECRET_SECRET_KEY}} --cli-project-id=00248baf96984aecac0f8a976fa7ac00 --cli-domain-id=5a9e34472c434dcabaf1d0c0d51e4efd --cli-read-timeout=20 --cli-connect-timeout=10
# Deploy Huawei Cloud CLI to CAE.
- name: Deploy to CAE
id: cli-command
run: |
echo y | sudo hcloud CAE ExecuteAction --cli-region="me-east-1" --project_id="00248baf96984aecac0f8a976fa7ac00" --X-Enterprise-Project-ID="0" --X-Environment-ID="811db361-727e-4b57-b247-584433244394" --application_id="8f179f8e-f914-4ae2-bbe8-c629973c7f50" --component_id="4b3998c3-9771-4337-a653-d90132d2dd77" --api_version="v1" --kind="Action" --metadata.name="upgrade" --metadata.annotations.version="1.0.0" --spec.source.type="image" --spec.source.url="swr.me-east-1.myhuaweicloud.com/demo-cae/cae-frontend:1.0.0"
- name: Print CLI command result
run: |
echo "Huawei Cloud CLI command output: ${{ steps.cli-command.outputs.result }}"
Check the running result.

Obtaining the Project ID, Region ID, Environment ID, Application ID, and Component ID
|
ID |
How to Obtain |
|---|---|
|
Project ID |
Log in to the management console, hover the cursor over the username in the upper right corner, and choose My Credentials from the drop-down list. On the API Credentials page, view the project ID in the project list.
|
|
Region ID |
Log in to the management console, hover the cursor over the username in the upper right corner, and choose My Credentials from the drop-down list. On the project list page, view the region ID in the Project Name column.
|
|
Environment ID |
Mouse over Environment to view the environment name and ID.
|
|
Application ID |
Mouse over Application to view the application name and ID.
|
|
Component ID |
Mouse over a component to view its name, version, and ID.
|
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot




