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

on: push

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

- name: Generate test files
run: |
mkdir -p files
echo "Minio Test 1" > files/test1.txt
echo "Minio Test 2" > files/test2.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: "./files/test1.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: "./files/*.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: "./files/*"
remote-path: "github/minio/"
5 changes: 0 additions & 5 deletions Dockerfile

This file was deleted.

57 changes: 47 additions & 10 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,50 @@ 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: |
echo "Will upload ${{ inputs.local-path }} to ${{ inputs.remote-path }}"
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")
IFS=$'\n'
for p in $(find "$local_dir" -maxdepth 1 -name "$local_files"); do
[ "$p" = "$local_dir" ] && continue
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 6d6009b

Please sign in to comment.