From 604de3036fd07ab8af8144783ee1690d492dd100 Mon Sep 17 00:00:00 2001 From: Dmitry Kalinin <8168727+ActiveChooN@users.noreply.github.com> Date: Tue, 22 Nov 2022 18:20:53 +0100 Subject: [PATCH] init commit --- Dockerfile | 5 +++++ README.md | 26 ++++++++++++++++++++++++++ action.yaml | 43 +++++++++++++++++++++++++++++++++++++++++++ entrypoint.sh | 14 ++++++++++++++ 4 files changed, 88 insertions(+) create mode 100644 Dockerfile create mode 100644 README.md create mode 100644 action.yaml create mode 100644 entrypoint.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f82d8de --- /dev/null +++ b/Dockerfile @@ -0,0 +1,5 @@ +FROM minio/mc:latest + +ADD entrypoint.sh /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..35746d5 --- /dev/null +++ b/README.md @@ -0,0 +1,26 @@ +# Minio download GitHub action + +Runs minio client (`mc cp` command) to download files from remote bucket + +# Usage + +Add this action to your `workflow.md` + +```yaml +- name: 'Minio download' + uses: 'ActiveChooN/minio-download-action@v1' + with: + endpoint: ${{ secrets.ENDPOINT }} + access_key: ${{ secrets.ACCESS_KEY }} + secret_key: ${{ secrets.SECRET_KEY }} + remote_path: 'path/on/remote/bucket' + local_path: 'path/on/local/runner' + # Optional params: + api_version: 'S3v4' + bucket: 'bucket_name' + args: '--recurcive' +``` + +# License + +Licensed under the MIT license. See [LICENSE](LICENSE). \ No newline at end of file diff --git a/action.yaml b/action.yaml new file mode 100644 index 0000000..f7594cf --- /dev/null +++ b/action.yaml @@ -0,0 +1,43 @@ +name: 'Minio download' +description: 'Download a file from S3 with Minio CLI' +author: 'ActiveChooN' +inputs: + endpoint: + description: 'Endpoint of object storage host' + required: true + access_key: + description: 'Access key' + required: true + secret_key: + description: 'Secret key' + required: true + remote_path: + description: 'Remote path' + required: true + local_path: + description: 'Local path' + required: true + bucket: + description: 'Bucket name' + api_version: + description: 'API version' + default: 'S3v4' + args: + description: 'Additional args passed to mc command' + default: '' +runs: + using: 'docker' + image: 'Dockerfile' + env: + ENDPOINT: ${{ inputs.endpoint }} + ACCESS_KEY: ${{ inputs.access_key }} + SECRET_KEY: ${{ inputs.secret_key }} + API: ${{ inputs.api }} + ARGS: ${{ inputs.args }} + BUCKET: ${{ inputs.bucket }} + args: + - ${{ inputs.remote_path }} + - ${{ inputs.local_path }} +branding: + icon: 'download-cloud' + color: 'green' \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..058c3c3 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,14 @@ +#!/bin/sh -l +set -euo pipefail + +sh -c "mc alias set action $ENDPOINT $ACCESS_KEY $SECRET_KEY $API" + +FULL_REMOTE_PATH=action + +if [ -n "$BUCKET" ]; then + FULL_REMOTE_PATH="$FULL_REMOTE_PATH/$BUCKET" +fi + +FULL_REMOTE_PATH="$FULL_REMOTE_PATH/$1" + +sh -c "mc cp $ARGS $FULL_REMOTE_PATH $2"