Skip to content

Commit

Permalink
支持全球加速推送
Browse files Browse the repository at this point in the history
  • Loading branch information
ic0xgkk committed Sep 6, 2021
1 parent 0745085 commit a1c9815
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 25 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 zkqiang
Copyright (c) 2021 Harris <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
21 changes: 9 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
[coscmd](https://cloud.tencent.com/document/product/436/10976)
工具,实现对象存储的批量上传、下载、删除等操作。

该仓库为修改版,非官方发布(官方仓库的Action压根就不能用)。仅支持全球加速,适合博客等个人建站使用

## workflow 示例

在目标仓库中创建 `.github/workflows/xxx.yml` 即可,文件名任意,配置参考如下:
Expand Down Expand Up @@ -35,28 +37,23 @@ jobs:
run: yarn && yarn build

- name: Upload COS
uses: zkqiang/tencent-cos-action@v0.1.0
uses: XUEGAONET/tencent-cos-action@v0.2.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
args: upload -rs --delete ./public/ /
secret_id: ${{ secrets.TENCENT_CLOUD_SECRET_ID }}
secret_key: ${{ secrets.TENCENT_CLOUD_SECRET_KEY }}
bucket: ${{ secrets.COS_BUCKET }}
```
其中 `${{ secrets.SECRET_XXX }}` 是调用 settings 配置的密钥,防止公开代码将权限密钥暴露,添加方式如下:

![](https://static.zkqiang.cn/images/20200118171056.png-slim)

其中 `${{ secrets.XXXXXXX }}` 是调用 settings 配置的密钥,防止公开代码将权限密钥暴露,需要自行前往仓库的设置中添加
## 相关参数

以下参数均可参见
[coscmd 官方文档](https://cloud.tencent.com/document/product/436/10976)

| 参数 | 是否必传 | 备注 |
| --- | --- | --- |
| args | 是 | coscmd 命令参数,参见官方文档,多个命令用 ` && ` 隔开<br>如 `delete -r -f / && upload -r ./dist/ /` |
| args | 是 | coscmd 命令参数,参见官方文档,多个命令用 ` && ` 隔开<br>如 `upload -rs --delete ./public/ /` |
| secret_id | 是 | 从 [控制台-API密钥管理](https://console.cloud.tencent.com/cam/capi) 获取 |
| secret_key | 是 | 同上 |
| bucket | 是 | 对象存储桶的名称,包含后边的数字 |
| region | 是 | 对象存储桶的地区,[参见文档](https://cloud.tencent.com/document/product/436/6224) |
9 changes: 3 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: 'Tencent COS Action'
description: 'GitHub Action for Tencent COS Command (coscmd)'
author: 'zkqiang <zkqiang@126.com>'
name: 'Tencent Accelerate COS Action(unofficial)'
description: 'GitHub Action for Tencent COS Command (coscmd) 全球加速域名专用,支持差异同步,适合静态网站'
author: 'Harris <i@xuegaogg.com>'
branding:
icon: 'cloud'
color: 'blue'
Expand All @@ -17,9 +17,6 @@ inputs:
bucket:
description: 'COS bucket name'
required: true
region:
description: 'COS bucket region, detail: https://cloud.tencent.com/document/product/436/6224'
required: true
runs:
using: 'docker'
image: 'Dockerfile'
7 changes: 1 addition & 6 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,7 @@ if [ -z "$INPUT_BUCKET" ]; then
exit 1
fi

if [ -z "$INPUT_REGION" ]; then
echo '::error::Required Region parameter'
exit 1
fi

coscmd config -a $INPUT_SECRET_ID -s $INPUT_SECRET_KEY -b $INPUT_BUCKET -r $INPUT_REGION -m 30
coscmd config -a $INPUT_SECRET_ID -s $INPUT_SECRET_KEY -b $INPUT_BUCKET -e cos.accelerate.myqcloud.com -m 30

IFS="&&"
arrARGS=($INPUT_ARGS)
Expand Down

0 comments on commit a1c9815

Please sign in to comment.