From a02e1dc69bf95bec8b5886641b381a83a2e39aa8 Mon Sep 17 00:00:00 2001 From: Scion Date: Thu, 27 Apr 2023 23:18:14 -0700 Subject: [PATCH] Added MinIO --- distros/busybox/action.yaml | 5 +-- distros/busybox/entrypoint.sh | 9 +++-- distros/rockylinux/Dockerfile | 18 --------- distros/rockylinux/action.yaml | 15 -------- distros/rockylinux/entrypoint.sh | 17 --------- distros/rockylinux/setup_gpg.sh | 29 --------------- dotnet/Dockerfile | 14 +++---- dotnet/action.yaml | 12 +++--- dotnet/entrypoint.sh | 2 + dotnet/startup.sh | 2 - minio/mc-cp/action.yaml | 55 +++++++++++++++++++++++++++ minio/mc-find/action.yaml | 64 ++++++++++++++++++++++++++++++++ minio/mc/Dockerfile | 7 ++++ minio/mc/action.yaml | 39 +++++++++++++++++++ minio/mc/entrypoint.sh | 25 +++++++++++++ 15 files changed, 212 insertions(+), 101 deletions(-) delete mode 100644 distros/rockylinux/Dockerfile delete mode 100644 distros/rockylinux/action.yaml delete mode 100644 distros/rockylinux/entrypoint.sh delete mode 100644 distros/rockylinux/setup_gpg.sh create mode 100644 dotnet/entrypoint.sh delete mode 100644 dotnet/startup.sh create mode 100644 minio/mc-cp/action.yaml create mode 100644 minio/mc-find/action.yaml create mode 100644 minio/mc/Dockerfile create mode 100644 minio/mc/action.yaml create mode 100644 minio/mc/entrypoint.sh diff --git a/distros/busybox/action.yaml b/distros/busybox/action.yaml index cfa7f14..2e0ea2f 100644 --- a/distros/busybox/action.yaml +++ b/distros/busybox/action.yaml @@ -1,9 +1,8 @@ name: busybox description: "Run busybox commands." inputs: - #Note: Passing in "args" overwrites the arguments passed into the container directly. args: - description: "Shell command to pass into busybox." + description: "Shell arguments to pass into busybox." required: true outputs: console: @@ -12,4 +11,4 @@ runs: using: docker image: Dockerfile args: - - ${{ inputs.args }} \ No newline at end of file + - ${{ inputs.args }} diff --git a/distros/busybox/entrypoint.sh b/distros/busybox/entrypoint.sh index f8ae402..3b44ee2 100644 --- a/distros/busybox/entrypoint.sh +++ b/distros/busybox/entrypoint.sh @@ -7,9 +7,10 @@ echo "$OUTPUT" #Output multiline strings. #https://trstringer.com/github-actions-multiline-strings/ -OUTPUT="${OUTPUT//'%'/'%25'}" -OUTPUT="${OUTPUT//$'\n'/'%0A'}" -OUTPUT="${OUTPUT//$'\r'/'%0D'}" -echo "::set-output name=console::$OUTPUT" +if [[ -n "$OUTPUT" ]]; then + echo "console<> "$GITHUB_OUTPUT" + echo "$OUTPUT" >> "$GITHUB_OUTPUT" + echo "EOF" >> "$GITHUB_OUTPUT" +fi exit $RESULT \ No newline at end of file diff --git a/distros/rockylinux/Dockerfile b/distros/rockylinux/Dockerfile deleted file mode 100644 index 46e88cf..0000000 --- a/distros/rockylinux/Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -# Container image that runs your code -FROM rockylinux:9.1 - -RUN dnf install -y \ - rpm-sign \ - unzip \ - pinentry \ - wget \ - zip - -COPY setup_gpg.sh /setup_gpg.sh -RUN chmod +x /setup_gpg.sh -RUN /setup_gpg.sh - -COPY entrypoint.sh /entrypoint.sh -RUN chmod +x /entrypoint.sh - -ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file diff --git a/distros/rockylinux/action.yaml b/distros/rockylinux/action.yaml deleted file mode 100644 index f3ecf63..0000000 --- a/distros/rockylinux/action.yaml +++ /dev/null @@ -1,15 +0,0 @@ -name: rockylinux -description: "Run rockylinux commands." -inputs: - #Note: Passing in "args" overwrites the arguments passed into the container directly. - args: - description: "Shell arguments to pass into Rocky Linux." - required: true -outputs: - console: - description: "The console output of the command." -runs: - using: docker - image: Dockerfile - args: - - ${{ inputs.args }} \ No newline at end of file diff --git a/distros/rockylinux/entrypoint.sh b/distros/rockylinux/entrypoint.sh deleted file mode 100644 index 5210574..0000000 --- a/distros/rockylinux/entrypoint.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh -WORKDIR=${WORKDIR:-.} -cd "$WORKDIR" - -ARGS="$@" -OUTPUT=$(bash -c "$ARGS") -RESULT=$? -echo "$OUTPUT" - -#Output multiline strings. -#https://trstringer.com/github-actions-multiline-strings/ -OUTPUT="${OUTPUT//'%'/'%25'}" -OUTPUT="${OUTPUT//$'\n'/'%0A'}" -OUTPUT="${OUTPUT//$'\r'/'%0D'}" -echo "::set-output name=console::$OUTPUT" - -exit $RESULT \ No newline at end of file diff --git a/distros/rockylinux/setup_gpg.sh b/distros/rockylinux/setup_gpg.sh deleted file mode 100644 index 1c6c3af..0000000 --- a/distros/rockylinux/setup_gpg.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash -#Importing gpg key via cli -#https://d.sb/2016/11/gpg-inappropriate-ioctl-for-device-errors -GPG_CONF="$HOME/.gnupg/gpg.conf" -GPG_AGENT_CONF="$HOME/.gnupg/gpg-agent.conf" - -function create_file -{ - FILE_PATH="$1" - CONTENTS="$2" - DIR=$(dirname "$FILE_PATH") - - mkdir -p "$DIR" - chmod 700 "$DIR" - echo "$CONTENTS" > "$FILE_PATH" -} - -create_file "$GPG_CONF" "$(cat <> "$GITHUB_OUTPUT" + shell: bash + - name: "Copy files to/from S3." + uses: act/common/minio/mc@master + with: + alias: ${{ inputs.alias }} + args: ${{ steps.command.outputs.command }} + accessKey: ${{ inputs.accessKey }} + secretKey: ${{ inputs.secretKey }} + url: ${{ inputs.url }} diff --git a/minio/mc-find/action.yaml b/minio/mc-find/action.yaml new file mode 100644 index 0000000..db3be19 --- /dev/null +++ b/minio/mc-find/action.yaml @@ -0,0 +1,64 @@ +name: mc-find +description: "Find files in s3." +inputs: + accessKey: + description: "S3 access key." + required: true + secretKey: + description: "S3 secret key." + required: true + alias: + description: "S3 alias." + required: true + url: + description: "S3 url." + required: true + default: https://s3-us-gov-west-1.amazonaws.com + path: + description: "The path to search for." + required: true + args: + description: "Additional arguments." + required: false +outputs: + files: + description: "The path of the found file." + value: ${{ steps.output.outputs.files }} + success: + description: "Whether files were found." + value: ${{ steps.output.outputs.success }} +runs: + using: "composite" + steps: + - name: "Build command." + id: command + run: | + COMMAND="find '${{ inputs.path }}' ${{ inputs.args }}" + echo "command=$COMMAND" >> "$GITHUB_OUTPUT" + shell: bash + - name: "Find file in S3." + id: find + uses: act/common/minio/mc@master + with: + alias: ${{ inputs.alias }} + args: ${{ steps.command.outputs.command }} + accessKey: ${{ inputs.accessKey }} + secretKey: ${{ inputs.secretKey }} + url: ${{ inputs.url }} + catchErrors: true + - name: "Set output." + id: output + run: | + RESULT="${{ steps.find.outputs.exitCode }}" + + if [[ "$RESULT" != "0" ]]; then + SUCCESS="false" + else + echo "files<> "$GITHUB_OUTPUT" + echo "${{ steps.find.outputs.console }}" >> "$GITHUB_OUTPUT" + echo "EOF" >> "$GITHUB_OUTPUT" + SUCCESS="true" + fi + + echo "success=$SUCCESS" >> "$GITHUB_OUTPUT" + shell: bash diff --git a/minio/mc/Dockerfile b/minio/mc/Dockerfile new file mode 100644 index 0000000..78b865a --- /dev/null +++ b/minio/mc/Dockerfile @@ -0,0 +1,7 @@ +# Container image that runs your code +FROM minio/mc:RELEASE.2023-01-11T03-14-16Z + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/minio/mc/action.yaml b/minio/mc/action.yaml new file mode 100644 index 0000000..307b446 --- /dev/null +++ b/minio/mc/action.yaml @@ -0,0 +1,39 @@ +name: mc +description: "Run MinIO Client mc commands." +inputs: + args: + description: "Arguments to pass into mc." + required: true + alias: + description: "S3 alias." + required: true + default: s3 + url: + description: "S3 URL." + required: true + default: https://s3-us-gov-west-1.amazonaws.com + accessKey: + description: "S3 access key." + required: true + secretKey: + description: "S3 secret key." + required: true + catchErrors: + description: "Whether or not errors should be handled." + required: false +outputs: + console: + description: "The console output of the aws command." + exitCode: + description: "How the program exited." +runs: + using: docker + image: Dockerfile + env: + CATCH_ERRORS: ${{ inputs.catchErrors }} + S3_URL: ${{ inputs.url }} + S3_ALIAS: ${{ inputs.alias }} + S3_ACCESS_KEY_ID: ${{ inputs.accessKey }} + S3_SECRET_ACCESS_KEY: ${{ inputs.secretKey }} + args: + - ${{ inputs.args }} diff --git a/minio/mc/entrypoint.sh b/minio/mc/entrypoint.sh new file mode 100644 index 0000000..e2d25c5 --- /dev/null +++ b/minio/mc/entrypoint.sh @@ -0,0 +1,25 @@ +#!/bin/sh +ARGS="$@" + +MC_CONFIG_DIR="/root/.mc" +mkdir -p "$MC_CONFIG_DIR" + +mc --config-dir "$MC_CONFIG_DIR" alias set "$S3_ALIAS" "$S3_URL" "$S3_ACCESS_KEY_ID" "$S3_SECRET_ACCESS_KEY" + +OUTPUT=$(bash -c "mc --config-dir $MC_CONFIG_DIR $ARGS") +RESULT=$? +echo "$OUTPUT" + +#Output multiline strings. +#https://trstringer.com/github-actions-multiline-strings/ +if [[ -n "$OUTPUT" ]]; then + echo "console<> "$GITHUB_OUTPUT" + echo "$OUTPUT" >> "$GITHUB_OUTPUT" + echo "EOF" >> "$GITHUB_OUTPUT" +fi + +echo "exitCode=$RESULT" >> "$GITHUB_OUTPUT" + +if [[ "$CATCH_ERRORS" != "true" ]]; then + exit $RESULT +fi