Skip to content

zkqiang/tencent-cos-action

Use this GitHub Action with your project

Add this Action to an existing workflow or create a new one.

View on Marketplace
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 

简介

GitHub Action 用于调用腾讯云 coscmd 工具,实现对象存储的批量上传、下载、删除等操作。

workflow 示例

在目标仓库中创建 .github/workflows/xxx.yml 即可,文件名任意,配置参考如下:

name: CI

on:
  push:
    branches:
      - master

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout master
        uses: actions/checkout@v2
        with:
          ref: master

      - name: Setup node
        uses: actions/setup-node@v1
        with:
          node-version: "10.x"

      - name: Build project
        run: yarn && yarn build

      - name: Upload COS
        uses: zkqiang/tencent-cos-action@v0.1.0
        with:
          args: delete -r -f / && upload -r ./dist/ /
          secret_id: ${{ secrets.SECRET_ID }}
          secret_key: ${{ secrets.SECRET_KEY }}
          bucket: ${{ secrets.BUCKET }}
          region: ap-shanghai

其中 ${{ secrets.SECRET_XXX }} 是调用 settings 配置的密钥,防止公开代码将权限密钥暴露,添加方式如下:

相关参数

以下参数均可参见 coscmd 官方文档

参数 是否必传 备注
args coscmd 命令参数,参见官方文档,多个命令用 && 隔开
delete -r -f / && upload -r ./dist/ /
secret_id 控制台-API密钥管理 获取
secret_key 同上
bucket 对象存储桶的名称,包含后边的数字
region 对象存储桶的地区,参见文档