云应用引擎 CAE-CAE对接GitHub Actions实现自动CICD部署:步骤二:配置GitHub Actions工作流文件,查看运行结果
时间:2025-11-13 16:11:18
步骤二:配置GitHub Actions工作流文件,查看运行结果
以下示例展示使用huawei cli配置GitHub Actions工作流文件,用于自动化构建、测试、打包Node.js应用并将其部署CAE。实际配置过程中,需根据实际情况调整。
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_AC CES S_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
# 下载并安装华为云 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
# 配置华为云 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
# 部署到华为云 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 "华为云 CLI 命令的返回结果: ${{ steps.cli-command.outputs.result }}"
查看运行结果:

support.huaweicloud.com/bestpractice-cae/cae_05_0064.html
下载云应用引擎 CAE用户手册完整版