Skip to content

Commit d79c263

Browse files
committed
Use prebuilt mc binary in place of docker image
Signed-off-by: Kostis Papazafeiropoulos <[email protected]>
1 parent d9ec71d commit d79c263

File tree

4 files changed

+95
-73
lines changed

4 files changed

+95
-73
lines changed

.github/workflows/test.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Test action
2+
3+
on: push
4+
5+
jobs:
6+
upload:
7+
runs-on: self-hosted
8+
steps:
9+
- name: Checkout repo
10+
uses: actions/checkout@v4
11+
12+
- name: Generate test files
13+
run: |
14+
echo "Minio Test" >> test.txt
15+
echo "Minio Test" >> test-wild.txt
16+
17+
- name: Test single file upload
18+
uses: ./
19+
with:
20+
url: https://s3.nubificus.com
21+
access-key: ${{ secrets.AWS_ACCESS_KEY }}
22+
secret-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
23+
local-path: "./test.txt"
24+
remote-path: "github/minio/"
25+
26+
- name: Test wildcard with extension upload
27+
uses: ./
28+
with:
29+
url: https://s3.nubificus.com
30+
access-key: ${{ secrets.AWS_ACCESS_KEY }}
31+
secret-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
32+
local-path: "./*.txt"
33+
remote-path: "github/minio/"
34+
35+
- name: Test wildcard upload
36+
uses: ./
37+
with:
38+
url: https://s3.nubificus.com
39+
access-key: ${{ secrets.AWS_ACCESS_KEY }}
40+
secret-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
41+
local-path: "./*"
42+
remote-path: "github/minio/"

Dockerfile

Lines changed: 0 additions & 5 deletions
This file was deleted.

action.yml

Lines changed: 53 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,56 @@ inputs:
2424
required: false
2525

2626
runs:
27-
using: 'docker'
28-
image: 'Dockerfile'
29-
entrypoint: '/entrypoint.sh'
30-
args:
31-
- ${{ inputs.url }}
32-
- ${{ inputs.access-key }}
33-
- ${{ inputs.secret-key }}
34-
- ${{ inputs.local-path }}
35-
- ${{ inputs.remote-path }}
36-
- ${{ inputs.policy }}
27+
using: composite
28+
steps:
29+
- name: Setup mc
30+
working-directory: /usr/local/bin
31+
run: |
32+
[ -n "$(which mc)" ] && exit 0
33+
arch=$(dpkg --print-architecture | sed 's/armhf/arm/g')
34+
sudo wget --progres=dot:binary \
35+
"https://dl.min.io/client/mc/release/linux-${arch}/mc"
36+
sudo chmod +x mc
37+
shell: bash
38+
39+
- name: Setup s3 alias
40+
run: |
41+
mc alias set s3 "${{ inputs.url }}" \
42+
"${{ inputs.access-key }}" "${{ inputs.secret-key }}"
43+
shell: bash
44+
45+
- name: Upload objects
46+
run: |
47+
local_path="${{ inputs.local-path }}"
48+
if [ "${local_path#*'*'}" != "$local_path" ]; then
49+
# Handle local_files with wildcards
50+
local_dir=$(dirname "$local_path")
51+
local_files=$(basename "$local_path")
52+
path_depth=$(echo "$local_dir" | awk -F"/" '{print NF-1}')
53+
echo "ld: $local_dir"
54+
echo "lf: $local_files"
55+
echo "pd: $path_depth"
56+
echo "-----------"
57+
IFS=$'\n'
58+
for p in $(mc find "$local_dir" \
59+
--name "$local_files" --maxdepth "$path_depth"); do
60+
echo "p: $p"
61+
echo "-----------"
62+
mc cp -r "$p" "s3/${{ inputs.remote-path }}"
63+
done
64+
unset IFS
65+
else
66+
mc cp -r "$local_path" "s3/${{ inputs.remote-path }}"
67+
fi
68+
shell: bash
69+
70+
- name: Set policy
71+
run: |
72+
if [ "${{ inputs.policy }}" = 1 ] ; then
73+
echo "Will make ${{ inputs.remote-path }} public"
74+
mc anonymous -r set download "s3/${{ inputs.remote-path }}"
75+
else
76+
echo "Will make ${{ inputs.remote-path }} private"
77+
mc anonymous -r set private "s3/${{ inputs.remote-path }}" || true
78+
fi
79+
shell: bash

entrypoint.sh

Lines changed: 0 additions & 58 deletions
This file was deleted.

0 commit comments

Comments
 (0)