Skip to content

Commit

Permalink
Use prebuilt mc binary in place of docker image
Browse files Browse the repository at this point in the history
Signed-off-by: Kostis Papazafeiropoulos <[email protected]>
  • Loading branch information
papazof committed Sep 28, 2024
1 parent 8494658 commit 4035a4c
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 87 deletions.
41 changes: 31 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,34 @@ on: push

jobs:
download:
runs-on: self-hosted
steps:
- uses: actions/checkout@v2
- uses: ./
with:
url: https://s3.nubificus.com
access-key: ${{ secrets.AWS_ACCESS_KEY }}
secret-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
local-path: "./"
remote-path: "github/test/test.txt"
runs-on: self-hosted
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Test single file download
uses: ./
with:
url: https://s3.nubificus.com
access-key: ${{ secrets.AWS_ACCESS_KEY }}
secret-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
local-path: "./"
remote-path: "github/minio/test1.txt"

- name: Test wildcard with extension download
uses: ./
with:
url: https://s3.nubificus.com
access-key: ${{ secrets.AWS_ACCESS_KEY }}
secret-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
local-path: "./"
remote-path: "github/minio/*.txt"

- name: Test wildcard download
uses: ./
with:
url: https://s3.nubificus.com
access-key: ${{ secrets.AWS_ACCESS_KEY }}
secret-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
local-path: "./"
remote-path: "github/minio/*"
5 changes: 0 additions & 5 deletions Dockerfile

This file was deleted.

45 changes: 36 additions & 9 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,39 @@ inputs:
required: true

runs:
using: 'docker'
image: 'Dockerfile'
entrypoint: '/entrypoint.sh'
args:
- ${{ inputs.url }}
- ${{ inputs.access-key }}
- ${{ inputs.secret-key }}
- ${{ inputs.local-path }}
- ${{ inputs.remote-path }}
using: composite
steps:
- name: Setup mc
working-directory: /usr/local/bin
run: |
[ -n "$(which mc)" ] && exit 0
arch=$(dpkg --print-architecture | sed 's/armhf/arm/g')
sudo wget --progres=dot:binary \
"https://dl.min.io/client/mc/release/linux-${arch}/mc"
sudo chmod +x mc
shell: bash

- name: Setup s3 alias
run: |
mc alias set s3 "${{ inputs.url }}" \
"${{ inputs.access-key }}" "${{ inputs.secret-key }}"
shell: bash

- name: Download objects
run: |
echo "Will download ${{ inputs.remote-path }} to ${{ inputs.local-path }}"
remote_path=${{ inputs.remote-path }}
if [ "${remote_path#*'*'}" != "$remote_path" ]; then
# Handle remote_files with wildcards
remote_dir=$(dirname "$remote_path")
remote_files=$(basename "$remote_path")
IFS=$'\n'
for p in $(mc find "s3/$remote_dir" \
--maxdepth 2 --name "$remote_files" | sort -u); do
mc cp -r "$p" "${{ inputs.local-path }}";
done
unset IFS
else
mc cp -r "s3/$remote_path" "${{ inputs.local-path }}"
fi
shell: bash
63 changes: 0 additions & 63 deletions entrypoint.sh

This file was deleted.

0 comments on commit 4035a4c

Please sign in to comment.