Github Action to upload Aliyun OSS

Database and Ruby, Python, History


通过Github Action上传OSS。需要注意的是-r -f需要写在末尾,否则会有一些莫可名状的行为。

Secret是设置在项目上面的。

name: Upload to Ali OSS on Main Merge

on:
  push:
    branches:
      - main

jobs:
  upload-to-aliyun-oss:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Install AWS CLI
        run: |
          sudo apt-get update
          sudo apt install -y curl
          sudo curl https://aliyuncli.alicdn.com/aliyun-cli-linux-latest-amd64.tgz -o aliyun-cli-linux-3.0.16-amd64.tgz
          sudo tar xzvf aliyun-cli-linux-3.0.16-amd64.tgz
          sudo cp aliyun /usr/local/bin
          aliyun version

      - name: Upload to Aliyun OSS
        env:
          ACCESS_KEY_ID: $
          SECRET_ACCESS_KEY: $
          REGION: cn-beijing
        run: |
          aliyun configure set --profile default --mode AK --region=cn-beijing --access-key-id=$ACCESS_KEY_ID --access-key-secret=$SECRET_ACCESS_KEY
          aliyun oss cp ./{your_folder}/ oss://{bucket} -r -f