Coder Social home page Coder Social logo

cos-action's Introduction

cos-action

Github Action to upload to Tencent Cloud COS

Inputs

secret_id

Required Tencent Cloud secret id. Should be referred to a encrypted environment variable.

secret_key

Required Tencent Cloud secret key. Should be referred to a encrypted environment variable.

cos_bucket

Required COS bucket name.

cos_region

Required COS bucket region.

local_path

Required Local path to be uploaded to COS. Directory or file is allowed.

remote_path

Required COS path to put the local files in on COS.

clean

Optional Set to true for cleaning files on COS path which are not existed in local path. Default is false.

accelerate

Optional Set to true for using accelerate domain to upload files. Default is false.

Example usage

uses: TencentCloud/cos-action@v1
with:
  secret_id: ${{ secrets.TENCENT_CLOUD_SECRET_ID }}
  secret_key: ${{ secrets.TENCENT_CLOUD_SECRET_KEY }}
  cos_bucket: ${{ secrets.COS_BUCKET }}
  cos_region: ${{ secrets.COS_REGION }}
  local_path: build
  remote_path: docroot/static
  clean: true

cos-action's People

Contributors

dependabot[bot] avatar mingshun avatar shirasawasama avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

cos-action's Issues

希望修改 README.md 中关于 `remote_path` 的描述

如题,因为在实现中 remote_path 用于 getBucketprefix 参数,而此参数并没有根目录概念,固填入 / 时会影响 clean 参数的使用。
而在常规实现(比如 coscmd)中会引入根目录的概念,易产生误导,建议加入提示。

clean option set to true KO?

嗨,大家好!
Sorry my Chinese skills are very basic so I will write this issue in English.

Here is my use case:

I write a blog with the well-known static site generator Hugo. My blog content is stored in a GitHub repository. Each time I push a commit with new content, a GitHub action triggers Hugo, which generates the new static files, then cos-action uploads the files to my COS bucket, bind to my domain name with Tencent Cloud CDN.

My GitHub deployment process looks like this:

name: Deploy Hugo on Tencent COS

on:
  push:
    branches: master

env:
  HUGO_VERSION: 0.78.2

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@master
        with:
          submodules: true

      - name: Download Hugo
        run: sudo wget -q https://github.com/gohugoio/hugo/releases/download/v${{ env.HUGO_VERSION }}/hugo_${{ env.HUGO_VERSION }}_Linux-64bit.deb

      - name: Install Hugo
        run: sudo dpkg -i hugo_${{ env.HUGO_VERSION }}_Linux-64bit.deb

      - name: Build Hugo
        run: hugo --cleanDestinationDir --enableGitInfo --gc --minify --disableKinds RSS

      - uses: TencentCloud/cos-action@master
        with:
          secret_id: ${{ secrets.TENCENT_CLOUD_SECRET_ID }}
          secret_key: ${{ secrets.TENCENT_CLOUD_SECRET_KEY }}
          cos_bucket: ${{ secrets.COS_BUCKET }}
          cos_region: ${{ secrets.COS_REGION }}
          local_path: public
          remote_path: /
          clean: true 

Hugo command always generates the whole static site, so the cos-action re-uploads all the files at each build. It may not be the most efficient but this is no problem since Hugo generates the blog files with the very same name.

The clean option comes really handy: if I remove or rename a file in my blog content, I want the original file (the one deleted or the one with the old name) to be removed from my COS bucket. There is no need for me to keep unnecessary old files. The problem is: the clean option set to true does not seem to function properly, at least not as I expect it to work.

Let me illustrate with an example:

  1. I add a new image test.png file to my Hugo blog. I commit the change and push it to Github:

image

  1. The GitHub action worked fine and the new generated files (37) including test.png were uploaded into my COS bucket:

image

image

  1. Now I rename the test.png into new_test.png, commit the change, push it to GitHub and wait for the action to kick in. Hugo command does not generate test.png, but only the renamed file new_test.png (37 files uploaded again).

image

image

  1. As you can see in my COS bucket, new_test.png was successfully uploaded to my COS bucket, but the cleaning I expected did not happen, the original test.png is still there:

image

  1. Last test: I delete new_test.png from my repo, and I commit the change.

image

  1. Hugo command will now generate 36 files instead of 37 files (no new_test.png):

image

  1. The expected behavior is that cos-action cleans new_test.png from the COS bucket. Unfortunately all the old files are still online in my bucket 😢 As you can see in the screenshot, the modification timestamp of each test file meets my previous build jobs with cos-action, so no cleaning happened.

image

Conclusion
Is this a real bug or am I misunderstanding how the clean option set to true should work? Is there a way for me to achieve what I need: automatically delete the files in my bucket that are not in the local path. For now, each time I make a change to my blog, I need to remove manually the old files from the bucket via my Tencent Cloud console.

Also I browsed through the COSCMD CLI tool documentation, it seems that there is no synchronization option between local path and bucket path, which would have been very convenient.

Thank you 谢谢

P.S. The very same tests performed with your competitor Google Cloud Platform actions worked just fine:

image

image

[bug]: get an error

[@octokit/rest] `const Octokit = require("@octokit/rest")` is deprecated. Use `const { Octokit } = require("@octokit/rest")` instead

屏幕截图 2022-02-24 201100

外网加速上传

请问是否可以使用cos的外网加速域名进行上传呢?
直接使用的话经常会上传失败,而且上传速度比较缓慢

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.