@@ -24,13 +24,51 @@ inputs:
2424 required : false
2525
2626runs :
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+ echo "Will upload ${{ inputs.local-path }} to ${{ inputs.remote-path }}"
48+ local_path=${{ inputs.local-path }}
49+ if [ "${local_path#*'*'}" != "$local_path" ]; then
50+ # Handle local_files with wildcards
51+ local_dir=$(dirname "$local_path")
52+ local_files=$(basename "$local_path")
53+ IFS=$'\n'
54+ for p in $(find "$local_dir" -maxdepth 1 -name "$local_files" | \
55+ sort -u); do
56+ [ "$p" = "$local_dir" ] && continue
57+ mc cp -r "$p" "s3/${{ inputs.remote-path }}"
58+ done
59+ unset IFS
60+ else
61+ mc cp -r "$local_path" "s3/${{ inputs.remote-path }}"
62+ fi
63+ shell : bash
64+
65+ - name : Set policy
66+ run : |
67+ if [ "${{ inputs.policy }}" = 1 ] ; then
68+ echo "Will make ${{ inputs.remote-path }} public"
69+ mc anonymous -r set download "s3/${{ inputs.remote-path }}"
70+ else
71+ echo "Will make ${{ inputs.remote-path }} private"
72+ mc anonymous -r set private "s3/${{ inputs.remote-path }}" || true
73+ fi
74+ shell : bash
0 commit comments