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

on: push

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

- run: |
echo "Minio Test" >> test.txt
echo "Minio Test" >> test-wild.txt
- 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/"

- 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/"
5 changes: 0 additions & 5 deletions Dockerfile

This file was deleted.

59 changes: 49 additions & 10 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,52 @@ 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}')
IFS=$'\n'
for p in $(mc find "$local_dir" \
--name "$local_files" --maxdepth "$path_depth"); do
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 c9682c3

Please sign in to comment.