华为云统一鉴权Action。此Action配置访问华为云时的身份凭证AK/SK(Access Key ID/Secret Access Key),区域region, 项目ID project id环境变量并对访问密钥AK/SK进行身份验证,以便在其他GitHub Actions操作中使用。
华为云统一鉴权Action需要了解华为云统一身份认证服务(Identity and Access Management,简称IAM)。
Name | Require | Default | Description |
---|---|---|---|
access_key_id | true | 华为云访问密钥ID即AK,可以在我的凭证获取。建议在GitHub项目的setting--Secret--Actions下添加 ACCESSKEY 参数 | |
secret_access_key | true | 华为云访问密钥即SK,可以在我的凭证获取。建议在GitHub项目的setting--Secret--Actions下添加SECRETACCESSKEY 参数 | |
region | true | cn-north-4 | 华为云区域,可以在我的凭证获取 |
project_id | false | 华为云项目ID,可以在我的凭证获取 |
在GitHub Workflow中添加下面的步骤
- name: Authenticate to Huawei Cloud
uses: huaweicloud/auth-action@v1.1.0
with:
access_key_id: ${{ secrets.ACCESSKEY }}
secret_access_key: ${{ secrets.SECRETACCESSKEY }}
region: 'cn-north-4'
# 下面使用华为云Actions的步骤会自动鉴权
使用前的workflow
jobs:
workflow_demo:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# 使用华为云命令行工具KooCLI
- name: List Versions of ECS With Default Region By KooCLI
uses: huaweicloud/huaweicloud-cli-action@v1.0.1
with:
access_key: ${{ secrets.ACCESSKEY }}
secret_key: ${{ secrets.SECRETACCESSKEY }}
region: 'cn-north-4'
commandList: 'hcloud ECS NovaListVersions'
# 上传文件到华为云OBS
- name: Upload To HuaweiCloud OBS
uses: huaweicloud/obs-helper@v1.2.0
id: upload_file_to_obs
with:
access_key: ${{ secrets.ACCESSKEY }}
secret_key: ${{ secrets.SECRETACCESSKEY }}
region: 'cn-north-4'
bucket_name: 'bucket-test'
local_file_path: 'src1/src2/test1.txt'
obs_file_path: ''
operation_type: 'upload'
使用后的workflow
jobs:
workflow_demo:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Authenticate to Huawei Cloud
uses: huaweicloud/auth-action@v1.1.0
with:
access_key_id: ${{ secrets.ACCESSKEY }}
secret_access_key: ${{ secrets.SECRETACCESSKEY }}
region: 'cn-north-4'
project_id: '<project_id>'
# 使用华为云命令行工具KooCLI
- name: List Versions of ECS With Default Region By KooCLI
uses: huaweicloud/huaweicloud-cli-action@v1.0.1
with:
commandList: 'hcloud ECS NovaListVersions'
# 上传文件到华为云OBS
- name: Upload To HuaweiCloud OBS
uses: huaweicloud/obs-helper@v1.2.0
id: upload_file_to_obs
with:
bucket_name: 'bucket-test'
local_file_path: 'src1/src2/test1.txt'
obs_file_path: ''
operation_type: 'upload'
从上面是否使用华为云统一鉴权Action对比可以看出,使用统计鉴权action之后华为云的GitHub Action步骤会自动鉴权,不需要在每个action输入鉴权信息
本action是华为云统一鉴权,使用过程会调用华为云的OpenAPI,涉及到的公网域名可到华为云地区和终端节点查看。