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 d9ec71d commit 3d0b172
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 73 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Test action

on: push

jobs:
upload:
runs-on: self-hosted
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Generate test files
run: |
echo "Minio Test" >> test.txt
echo "Minio Test" >> test-wild.txt
- name: Test single file upload
uses: ./
with:
url: https://s3.nubificus.com
access-key: ${{ secrets.AWS_ACCESS_KEY }}
secret-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
local-path: "./test.txt"
remote-path: "github/minio/"

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

- name: Test wildcard upload
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.

64 changes: 54 additions & 10 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,57 @@ inputs:
required: false

runs:
using: 'docker'
image: 'Dockerfile'
entrypoint: '/entrypoint.sh'
args:
- ${{ inputs.url }}
- ${{ inputs.access-key }}
- ${{ inputs.secret-key }}
- ${{ inputs.local-path }}
- ${{ inputs.remote-path }}
- ${{ inputs.policy }}
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: Upload objects
run: |
local_path="${{ inputs.local-path }}"
if [ "${local_path#*'*'}" != "$local_path" ]; then
# Handle local_files with wildcards
local_dir=$(dirname "$local_path")
local_files=$(basename "$local_path")
path_depth=$(echo "$local_dir" | awk -F"/" '{print NF-1}')
echo "ld: $local_dir"
echo "lf: $local_files"
echo "pd: $path_depth"
echo "-----------"
IFS=$'\n'
for p in $(mc find "$local_dir" \
--name "$local_files" --maxdepth "$path_depth"); do
[ "$p" = "$local_dir" ] && continue
echo "p: $p"
echo "-----------"
#mc cp -r "$p" "s3/${{ inputs.remote-path }}"
done
unset IFS
else
mc cp -r "$local_path" "s3/${{ inputs.remote-path }}"
fi
shell: bash

- name: Set policy
run: |
if [ "${{ inputs.policy }}" = 1 ] ; then
echo "Will make ${{ inputs.remote-path }} public"
mc anonymous -r set download "s3/${{ inputs.remote-path }}"
else
echo "Will make ${{ inputs.remote-path }} private"
mc anonymous -r set private "s3/${{ inputs.remote-path }}" || true
fi
shell: bash
58 changes: 0 additions & 58 deletions entrypoint.sh

This file was deleted.

0 comments on commit 3d0b172

Please sign in to comment.